Garrett Goebel wrote:
> 
> I'd be surprised if 
> 
> sub mygrep (&@) {
>   my ($coderef, @list, @stack) = @_;
>   &$coderef and push(@stack, $_)  foreach (@list);
>   return @stack;
> }
> 
> @a = mygrep { return ($_ <= 2) ? 1 : 0 } (1, 2, 3, 2, 1);
> print "\@a = @a\n";
> 
> Resulted in: @a = 
> Instead of the current Perl 5:  @a = 1 2 2 1

Yes!  *Exactly* my point!  Blocks should quack the same whether
I pass them to the built-in grep or to my own sub; i.e. they're
anonymous subs, not some magico-special "looping" blocks.

-- 
John Porter

        We're building the house of the future together.

Reply via email to