Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by SolidState (Scribe)
on Nov 13, 2005 at 12:59 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found