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

Re: Always Follow Up on Warnings

by blakem (Monsignor)
on Feb 07, 2002 at 20:58 UTC ( #143970=note: print w/ replies, xml ) Need Help??


in reply to Always Follow Up on Warnings

I've been known to rant about uninitialized warnings before... Here is one nice idiom for "cleaning" a series of undefined values.

$_ = '' for grep !defined, ($x,$y,$z);
Try the following code with and w/o this clensing line:
#!/usr/bin/perl -wT use strict; my ($x,$y,$z) = (undef,'hello',undef); # undef "clensing" idiom $_ = '' for grep !defined, ($x,$y,$z); print "x='$x' y='$y' z='$z'\n";

-Blake


Comment on Re: Always Follow Up on Warnings
Select or Download Code
(crazyinsomniac) Re^2: Always Follow Up on Warnings
by crazyinsomniac (Prior) on Feb 08, 2002 at 04:00 UTC
      The problem with $_ ||= '' is that it turns 0's into ''. defined is much less cool, but definitely more effective.

      --Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2015-07-04 05:23 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 (57 votes), past polls