Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: undef and empty variables

by ikegami (Patriarch)
on Jan 19, 2011 at 17:02 UTC ( [id://883162]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub empty_to_undef {
       return defined($_[0]) && !length($_[0]) ? undef : $_[0];
    }
    
  2. or download this
    sub empty_to_undef {
       no warnings 'uninitialized'; 
       return length($_[0]) ? $_[0] : undef;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found