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;
for only consumes from $fh.lines as needed