First of all for and given are not equivalent, they differ subtly in the scoping of their $_ variable:
use strict; use warnings; use 5.010; $_ = 42; sub f { say } given (23) { f } for (23) { f } __END__ 42 23
So given creates a new lexical $_, while for localizes the existing $_, which results in dynamic scoping.
But the real reason is that code must be readable to humans, and for has the connotation of a loop, whereas given makes it implicit that it's one value that is talked about. So it's all about intent.
In reply to Re: given and for
by moritz
in thread given and for
by GlitchMr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |