Larry Wall wrote:
But here's the kicker. The null filename can again represent the standard filter input, so we end up with Perl 5's
while (<>) {...}
turning into
for =<> {...}
Two more issues: idiom, and topification
===== Topification:
There are cases in P5 when I *don't* want
while (<>) {...}
but prefer
while ($input = <>) {...}
so that I can have something else be the topic. Every example to date has used C<for>:
for .lines {...}
but that sets the topic. I'm a little fuzzy on this, but doesn't C<for> play topic games even in this?
for .lines -> $input { ... $input ... }
That is, even though "$_" remains unaffected, doesn't this affect smartmatch etc.?
===== Idiom:
The other concern is idiom. Using C<for> suggests "start at the beginning, continue to the end". OTOH, using C<while> is a little "weaker" -- "keep doing this until it's time to stop". Obviously they'll usually be used in the same way:
for =<> {...} vs. while (<>) {...}
This seems a subtle concern, and maybe it's just my latent fear of change making me uncomfortable, but I actually *think* in english -- not that it does much good -- and this isn't how I think.
Can we ditch C<for> in the examples in favor of C<while>, for a while? :)
=Austin