Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 chilling in the Monastery: (6)
As of 2014-10-24 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls