Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Problems? Is your data what you think it is?
 
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 contemplating the Monastery: (6)
As of 2014-04-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls