Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement limit to IO.lines
  • Loading branch information
moritz committed Apr 20, 2009
1 parent 2703c20 commit ae5e785
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/setting/IO.pm
Expand Up @@ -15,9 +15,10 @@ class IO is also {
return $!ins;
}

multi method lines() is export {
my @result = ();
while !$.eof {
multi method lines($limit = *) is export {
my @result;
my $l = $limit ~~ Whatever ?? Inf !! $limit;
while !$.eof && $l-- > 0 {
push @result, $!PIO.readline().chomp()
}
return @result;
Expand Down

0 comments on commit ae5e785

Please sign in to comment.