Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Undefined vs empty string

by Athanasius (Archbishop)
on Jun 05, 2013 at 02:29 UTC ( [id://1037090]=note: print w/replies, xml ) Need Help??


in reply to Undefined vs empty string

undef and "" are indeed different in Perl, but both are boolean false, so the test can be simplified to:

if (!$string) { }

See perlsyn#Truth-and-Falsehood.

Update: Except that "0" is also false, so if that’s a possibility, prefer BrowserUk’s solution, below.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

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

    No recent polls found