Kickstarter: Learning Perl 6
kickstarter.com3 pointsby Ulti0 comments
use warnings;
use autodie;
To get similar functionality as the implicit Perl 6 IO error system. Reading from a file:
#Efficiently line by line for STDIN
for lines() -> $line {
$line.say;
}
#Get everything in RAM right now
my $string = "filename".IO.slurp;
#Lazy list will do IO as you request into the list
my @lines = "filename".IO.lines;
#Listing of directories if the path is a directory
my @directories = "coolstuff".IO.dir if "coolstuff".IO.d;
Playing with dates:
#Get a DateTime for right now
my $date = DateTime.now;
#Does what it says on the tin
say "Yippee" if $date.later(:5years).is-leap-year;