in reply to Help need in Miscellaneous code
Which part of it is confusing?
I suspect you wonder why $x is undefined.
The for loop sets $_, but does not localize it. readZip() reads into $_, and the last line read is undef. That's why the while loop terminates.
for loops alias the control variable to the values iterated -- and readZip() modifies $_, which is an alias for $x within the loop. When the loop ends, $x still holds the last value assigned to $_ within the loop: undef.
local $_; at the start of readZip() would fix this. (You also don't need the prototype.)
Update: Removed some very unclear text, thanks to ikegami.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help need in Miscellaneous code
by ikegami (Patriarch) on Apr 12, 2006 at 04:55 UTC |