Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: defined() might be a good idea

by demerphq (Chancellor)
on Aug 18, 2002 at 17:28 UTC ( [id://191000]=note: print w/replies, xml ) Need Help??


in reply to Re: defined() might be a good idea
in thread Check on if statement

I havent read the rest of the thread, I only comment because of your mistake in the cb ;-), but the test you describe:
if ( defined($foo) and $foo eq '?' ) { print "\$foo OK!\n"; }
Would be better (Lazier) written
print "\$foo OK!\n" if $foo and $foo eq '?';
in my opinion anyway...

Note that since $foo must be a '?', then it cant be _any_ false value, defined being only one of three. Thus you can dispose of the defined test and replace it with simple true or false.

Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-29 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found