in reply to for vs foreach?

I find that "foreach" does wonders for readability in situations like this:
sub foo { my $array = @_; foreach ($array) { do stuff; } # ... }
Your mileage may vary, of course.

/s

Update: I guess the joke doesn't come across as well on screen.

s/readability/job security/

Replies are listed 'Best First'.
Re^2: for vs foreach?
by tadman (Prior) on May 07, 2002 at 06:13 UTC
    Maybe this is just an inadvertent mistake, but think about what would happen with foo('bad','llama'):
    sub foo { my $array = @_; foreach ($array) { print "$_\n"; } }
    Watch how you assign from an array, because you could end up in jail!