in reply to Re^2: Problem with while loop inside a foreach loop
in thread Problem with while loop inside a foreach loop

map or grep are much much safer than for or foreach.

No they aren't :) They alias just like for/foreach.

I know that this is quite far-fetched LISP-like Perl code

Not really :)

  • Comment on Re^3: Problem with while loop inside a foreach loop

Replies are listed 'Best First'.
Re^4: Problem with while loop inside a foreach loop
by Laurent_R (Canon) on May 04, 2013 at 11:02 UTC

    No they aren't :) They alias just like for/foreach.

    I know that they alias the same way. But for some reason, I found that nesting foreach statements with the default $_ variable often seems to lead to confusions between the internal and the external values of $_, while I do not have this problem with nested map statements. But it is also possible that I simply don't do it right with the nesting of foreach statement. I don't do that too often anyway, I usually prefer to use explicit variables when nesting such statements in production code.