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

Perl 6 lazy list example #1

Perl 6 version, using lazy lists:

use v6;

# open file.txt for reading
my $fh = open('file.txt');

# read lines until blank found
for $fh.lines { last if /^\s*$/ }

# read the next line and display it
say $fh.get;

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