Skip to content

Instantly share code, notes, and snippets.

@colomon
Created August 21, 2010 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colomon/542357 to your computer and use it in GitHub Desktop.
Save colomon/542357 to your computer and use it in GitHub Desktop.
class LinesIter is Iterator {
has $.filehandle;
has $.value;
method infinite() { False }
method reify() {
say "errrr?";
unless $.value.defined {
my $parcel := pir::new('Parcel');
my $line = $.filehandle.get;
say $line;
if $line.defined {
pir::push($parcel, $line);
pir::push($parcel, LinesIter.new(:filehandle($.filehandle)));
}
$.value = $parcel;
}
$.value;
}
}
say "got here...";
my $count = 0;
for LinesIter.new(:filehandle($*IN)).list {
$count++;
}
say :$count.perl;
##########################################################
Wynne:rakudo colomon$ ./perl6 tt4.pl <tenthousand.txt
got here...
errrr?
Project Gutenberg's Songs of Angus and More Songs of Angus, by Violet Jacob
Cannot modify readonly value
in '&infix:<=>' at line 1
in 'LinesIter::reify' at line 17:tt4.pl
in main program body at line 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment