Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

spacebat's scratchpad

by spacebat (Beadle)
on Aug 19, 2007 at 09:36 UTC ( #633574=scratchpad: print w/ replies, xml ) Need Help??

Most painful lesson learnt:

Allocation and assignment don't always happen together in a 'my' statement. Subroutine scratchpads can persist and hold on to old values.

my $var = 'value' if $condition; # this can bite

This is better written as:

my $var = $condition ? 'value' : undef; # assignment always happens
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2015-07-02 04:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls