Skip to content

Commit

Permalink
Merge 5b39454 into 87c67d0
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaerxess committed Jul 21, 2014
2 parents 87c67d0 + 5b39454 commit 9fa999c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/Syntax/Keyword/Gather.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ or to use the stuff that L<Sub::Exporter> gives us, try
# this is a silly idea
use syntax gather => {
gather => { -as => 'bake' },
take => { -as => 'cake' },
gather => { -as => 'bake' },
take => { -as => 'cake' },
};
my @vals = bake { cake (1...10) };
Expand Down Expand Up @@ -215,14 +215,14 @@ first line they have in common. We could gather the lines like this:
}
}
If you like it really short, you can also gather-take $_ magically:
If you like it really short, you can also C<gather>/C<take> $_ magically:
my @numbers_with_two = gather {
my @numbers_with_two = gather {
for (1..20) {
take if /2/
take if /2/
}
};
# @numbers_with_two contains 2, 12, 20
};
# @numbers_with_two contains 2, 12, 20
Be aware that $_ in Perl5 is a global variable rather than the
current topic like in Perl6.
Expand All @@ -239,14 +239,8 @@ This module was forked from Damian Conway's L<Perl6::Gather> for a few reasons.
=item ~ doesn't overload to mean string context
=item to no longer takes the current topic ($_)
=back
The last item is actually due to an unintended side-effect of the fact that if
C<take> has an array of zero length it takes $_, which is surprising at the very
least. I'll fix that issue if I can.
=head1 BUGS AND IRRITATIONS
It would be nice to be able to code the default case as:
Expand Down

0 comments on commit 9fa999c

Please sign in to comment.