Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl Style: Is initializing variables considered taboo?

by FloydATC (Chaplain)
on Aug 24, 2010 at 15:58 UTC ( #856971=note: print w/ replies, xml ) Need Help??


in reply to Perl Style: Is initializing variables considered taboo?

If the undef has a significant meaning, I define it explicitly to make the code as clear as possible. Otherwise, I spend my keystrokes elsewhere. For example:

my $found = undef; foreach my $candidate (@candidates) { if ( good($candidate) ) { $found = $candidate; last; } } if (defined $found) { print "Found a good candidate: $found\n"; }

-- Time flies when you don't know what you're doing


Comment on Re: Perl Style: Is initializing variables considered taboo?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://856971]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-12-27 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls