File: basic.pl

package info (click to toggle)
libdirectory-scratch-perl 0.18-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 400 kB
  • sloc: perl: 1,173; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 783 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
# basic.pl 
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>

use strict;
use warnings;
use Directory::Scratch;

=pod

Guided tour of Directory::Scratch.

First, create a Directory::Scratch object

=cut

my $tmp = Directory::Scratch->new;

=pod

Then create a file.

=cut

print "Hello reader!  Welcome to this Knuth-like journey!\n";

my $file = $tmp->touch('foo');
print "foo was created as $file\n";

=pod

We dont't have to remember $file, we can get the full path later:

=cut

my $path = $tmp->exists('foo');
print "$file and $path are the same\n";

=pod

C<exists> also checks for existence, of course.

=cut

print "No file called fake!\n" if(!$tmp->exists('fake'));

=pod

That's all for now.

=cut

print "Goodbye.  I'm cleaning up $tmp for you!";