Skip to content

Commit

Permalink
keep lines() with limit from reading an extra line
Browse files Browse the repository at this point in the history
  • Loading branch information
labster committed Jun 2, 2013
1 parent 9557da2 commit 9cf3a88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/IO.pm
Expand Up @@ -140,7 +140,7 @@ my class IO::Handle does IO::FileTestable {

method lines($limit = $Inf) {
my $count = 0;
gather while (my $line = self.get).defined && ++$count <= $limit {
gather while ++$count <= $limit && (my $line = self.get).defined {
take $line;
}
}
Expand Down

0 comments on commit 9cf3a88

Please sign in to comment.