in reply to Re: Internally, how do for() and while() differ?
in thread Internally, how do for() and while() differ?
The two examples are equivalent in operation, since they have the <> operator around a file handle. In the case of arrays, which the OP did not specify, you are correct. Unless, again, the <> operator is used.
@a = qw(a b c); for(<@a>) { print "$_\n" }; while(<@a>) { print "$_\n" };
Both produce the same output, the while loop with considerably more efficiency for large datasets.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Internally, how do for() and while() differ? (readline vs glob)
by LanX (Saint) on Oct 28, 2015 at 00:15 UTC | |
by GotToBTru (Prior) on Oct 28, 2015 at 12:10 UTC |