Perl6-Gather
view release on metacpan or search on metacpan
lib/Perl6/Gather.pm view on Meta::CPAN
package Perl6::Gather;
use Perl6::Export;
use Carp;
our $VERSION = '0.42';
my %gatherers;
sub gather(&) is export(:DEFAULT) {
croak "Useless use of 'gather' in void context" unless defined wantarray;
my ($code) = @_;
my $caller = caller;
local @_;
push @{$gatherers{$caller}}, bless \@_, 'Perl6::Gather::MagicArrayRef';
die $@
if !eval{ &$code } && $@ && !UNIVERSAL::isa($@, Perl6::Gather::Break);
return @{pop @{$gatherers{$caller}}} if wantarray;
return pop @{$gatherers{$caller}} if defined wantarray;
}
( run in 0.343 second using v1.01-cache-2.11-cpan-49f99fa48dc )