Here's something that's rather crass, but maybe something like it will save you from venturing into dark regions:
c:\@Work\Perl\monks>perl -wMstrict -le
"sub working {
my @x = (1, 0, 2);
my @y = grep { print qq{in grep: '$_'}; return 'byebye'; } @x;
print 'still in working(): ', qq{(@y)};
return @y;
}
my @z = working;
print qq{from working(): (@z)};
"
in grep: '1'
from working(): (byebye)
c:\@Work\Perl\monks>perl -wMstrict -le
"sub mygrep (&@) {
my $code = shift;
my @result;
for (@_) {
no warnings 'exiting';
push(@result, $_)
if map { print 'in map: ', qq{'$_'}; $_; } &$code;
}
MYGREP_FINAL:
return @result;
}
;;
sub notworking {
my @x = (4, 0, 3);
my @y = mygrep {
print qq{in mygrep: '$_'}; goto MYGREP_FINAL;
} @x;
print 'still in notworking(): ', qq{(@y)};
return @y;
}
;;
my @z = notworking;
print qq{from notworking(): (@z)};
"
in mygrep: '4'
still in notworking(): ()
from notworking(): ()
Give a man a fish: <%-{-{-{-<