Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl Warnings...

by matija (Priest)
on Jan 27, 2009 at 18:49 UTC ( #739295=note: print w/ replies, xml ) Need Help??


in reply to Perl Warnings...

I like to run with warnings on. But sometimes I don't see them, like for instance, when I was editing a fairly substantial mod_perl script, which printed a whole bunch of stuff to the log, hiding any warnings in the scrollback.

Because I didn't see the warnings, I spent some frustrating time trying to discover what is going on in code that went something like this:

my $some_index = 0; while ($thing = $thingies->next) { my $some_index = $thing->something_or_other; last if (test_for_fitness($some_index)); }

Yeah, I had originally declared the variable in the loop, but then I realized I would need it outside the loop, moved the declaration out, and forgot to remove the inner my. The loop worked perfectly, but the moment the program left the loop, $some_index was restored to 0 again.

And that is why I like perl warning me about a re-used my declaration.

I know it's not what you asked, just some food for thought


Comment on Re: Perl Warnings...
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-09-22 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls