in reply to Re: Ways to control a map() operation
in thread Ways to control a map() operation
What’s the point? Just use a foreach already.
my @arr = 3..9 ; our @early; sub{ for( @arr ) { print; return if $_ == 5; push @early, $_; } }->(); print "@early";
Of course, that’s just an obfuscated way of writing the following:
my @arr = 3..9 ; our @early; for( @arr ) { print; last if $_ == 5; push @early, $_; } print "@early";
So no, there’s no sensible way to abort a map early.
Makeshifts last the longest.
|
|---|