Perl 6 Perl 6 Lists, Arrays, and Hashes vivified #20

Perl 5 lists are eager

Naive (i.e., incorrect) Perl 5 program to print the line following the first blank line in a file:

# P5 code!

# open file.txt
open my $fh, '<', 'file.txt' or die;

# read from file.txt until we find a blank line
foreach (<$fh>) { last if /^\s*$/ }

# read the next line and print it
my $line = <$fh>;
print $line;

close $fh;
continued...
Copyright © 2011
http://www.pmichaud.com/2011/pres/