in reply to Re: Hmmm: while(), file handle and $_ gotcha
in thread Hmmm: while(), file handle and $_ gotcha
moritz:
OK, that explains it. (I had an incorrect mental model: I was thinking that <FH> always put the data somewhere, using $_ unless otherwise specified. I don't know how I came to think that, as in hindsight that would be clearly stupid. Oh, well--live and learn!)
So the correct fix to my program would is to change the inner loop from:
for my $cnt (0 .. 3) { my $t=<DATA>; print $t; }
to
for my $cnt (0 .. 3) { $_=<DATA>; print; }
so I can avoid unnecessary variables and clutter.
Thank you!
...roboticus
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Hmmm: while(), file handle and $_ gotcha
by ikegami (Patriarch) on Mar 06, 2009 at 13:55 UTC | |
by hbm (Hermit) on Mar 06, 2009 at 14:12 UTC | |
by ikegami (Patriarch) on Mar 06, 2009 at 16:15 UTC | |
Re^3: Hmmm: while(), file handle and $_ gotcha
by webfiend (Vicar) on Mar 06, 2009 at 17:40 UTC | |
by ikegami (Patriarch) on Mar 06, 2009 at 17:48 UTC | |
by Porculus (Hermit) on Mar 06, 2009 at 21:47 UTC |
In Section
Seekers of Perl Wisdom