Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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 chanting in the Monastery: (5)
As of 2014-08-02 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls