1#!/usr/bin/perl 2# basic.pl 3# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org> 4 5use strict; 6use warnings; 7use Directory::Scratch; 8 9=pod 10 11Guided tour of Directory::Scratch. 12 13First, create a Directory::Scratch object 14 15=cut 16 17my $tmp = Directory::Scratch->new; 18 19=pod 20 21Then create a file. 22 23=cut 24 25print "Hello reader! Welcome to this Knuth-like journey!\n"; 26 27my $file = $tmp->touch('foo'); 28print "foo was created as $file\n"; 29 30=pod 31 32We dont't have to remember $file, we can get the full path later: 33 34=cut 35 36my $path = $tmp->exists('foo'); 37print "$file and $path are the same\n"; 38 39=pod 40 41C<exists> also checks for existence, of course. 42 43=cut 44 45print "No file called fake!\n" if(!$tmp->exists('fake')); 46 47=pod 48 49That's all for now. 50 51=cut 52 53print "Goodbye. I'm cleaning up $tmp for you!"; 54