Skip to content

Commit d393e53

Browse files
committed
import a start of cookbook section 9
1 parent 37f84e2 commit d393e53

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use v6;
2+
3+
=begin pod
4+
5+
=head1 Get/Set Filetime
6+
7+
You want to get and set a utime on a file's inode
8+
9+
=end pod
10+
11+
my $fn = $?FILE;
12+
13+
my Instant $i = $fn.IO.accessed;
14+
my $dt = $i.to-posix;
15+
16+
say :$dt.perl;
17+
18+
# vim: ft=perl6
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use v6;
2+
3+
=begin pod
4+
5+
=head1 Delete File
6+
7+
You want to delete a file
8+
9+
=end pod
10+
11+
# create a file
12+
my $f = open "foo",:w;
13+
$f.print(time);
14+
$f.close;
15+
16+
unlink "foo";
17+
18+
# vim: ft=perl6
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use v6;
2+
3+
=begin pod
4+
5+
=head1 Copy/Move File
6+
7+
You want to copy and move a file
8+
9+
=end pod
10+
11+
# create a file
12+
my $f = open "foo",:w;
13+
$f.print(time);
14+
$f.close;
15+
16+
# copy
17+
my $io = IO::Path.new("foo");
18+
$io.copy("foo2");
19+
20+
# clean up
21+
unlink ("foo2");
22+
23+
# move
24+
$io.rename("foo2");
25+
26+
# clean up
27+
unlink ("foo2");
28+
29+
# vim: ft=perl6
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use v6;
2+
3+
=begin pod
4+
5+
=head1 Process all files in a directory
6+
7+
You want to process all files in a directory
8+
9+
=end pod
10+
11+
for dir(".") -> $f {
12+
say $f.perl;
13+
}
14+
15+
16+
# vim: ft=perl6

0 commit comments

Comments
 (0)