http://qs1969.pair.com?node_id=508100


in reply to Re^3: Last undefines a for loop's itererator?
in thread Last undefines a for loop's itererator?

On the contrary, it's very relevant. In fact, the original question is I think a great example of the importance of using strict and warnings.

In the original code, the loop variable $picture was not pre-declared outside the loop using my (as you did for your $x). Had the OP run his code under use strict;, it would have died at compile time, perhaps prompting the OP to take a closer look at his code - exactly the thing I want use strict; to do for me.

Even with strict-compliant code similiar to yours, the OP would have gotten an informative message, rather then just an empty string, when using use warnings; - namely, the Use of uninitialized value in print message. There is it, staring him in the face - $picture is not initialized.

It's true that the warning does not explain why there is a problem. But in my experience, understanding exactly where the problem lies, is half-way to solving it.