in reply to Re^2: How foreach loops decide what to iterate through (push array inside foreach)
in thread How foreach loops decide what to iterate through
Would be nice if someone could show me a case where perl gets confused. I could not create one
Confused by addition:
>perl -wle"@a=1; for ((),@a) { push @a,$_+1; print }" 1 >perl -wle"@a=1; for (@a) { push @a,$_+1; print }" 1 2 3 4 ...
Confused by deletion:
>perl -wle"@a=(1,2); for (@a) { pop @a; print qq{<$_>} }" <1> >perl -wle"@a=(1,2); for ((),@a) { pop @a; print qq{<$_>} }" <1> Use of freed value in iteration at -e line 1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How foreach loops decide what to iterate through (push array inside foreach)
by jethro (Monsignor) on Feb 14, 2009 at 05:25 UTC | |
by ikegami (Patriarch) on Feb 14, 2009 at 05:37 UTC |