Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
doc
/
perl-Directory-Scratch
/
examples
Upload
3 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
basic.pl
783 B
-rw-r--r--
2015-01-20 02:59:47
Edit
Del
Editing: basic.pl
(783 B)
Path: /usr/share/doc/perl-Directory-Scratch/examples/basic.pl
Back
#!/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!";