Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^4: Last undefines a for loop's itererator?

by SolidState (Scribe)
on Nov 13, 2005 at 12:59 UTC ( #508100=note: print w/replies, xml ) Need Help??

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.

  • Comment on Re^4: Last undefines a for loop's itererator?

Replies are listed 'Best First'.
Re^5: Last undefines a for loop's itererator?
by Aristotle (Chancellor) on Nov 13, 2005 at 22:11 UTC

    The OP’s code is obviously just a snippet, not his entire source. How do you know he didn’t use strict and warnings?

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://508100]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-03-22 22:13 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.