Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 imbibing at the Monastery: (17)
As of 2015-07-29 16:26 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 (265 votes), past polls