Anyone Know Why Perl Does This?
Michael Slack
mslack at ameritech.net
Fri Jan 7 00:11:05 CST 2000
Sorry if you are getting this message twice. I'm not sure if it went out the
first time. Also, I think my original explanation may not have been clear.
It looks like $i went out of scope AFTER the successful test at line 16 and
AFTER next is called. Then Perl executes the continue statement BEFORE the
next pass through the loop. Thus you get the error when you try to execute
the continue statement (since $i is now undefined). I have made similar
errors in the past, and have concluded that declaring "my" variables inside of
control structures is usually a bad idea. Too many weird things can happen,
and it is always easy enough to declare them inside a block containing the
loop (as you did in your successful version).
Cheers,
Mike
--
Michael Slack
mslack at ameritech.net
--
"If we knew what it was we were doing, it wouldn't
be called research, would it?" --Albert Einstein
More information about the grand-rapids-pm-list
mailing list