Debian Codegraph @

examples/basic.pl

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