School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,421 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,523 people online right now. Registration is fast and FREE... Join Now!




Checking undef

 

Checking undef

Sun751

22 Jun, 2009 - 11:46 PM
Post #1

D.I.C Head
**

Joined: 11 Dec, 2008
Posts: 57



Thanked: 1 times
My Contributions
I have got the code where these two variable are defined at some point where as undef in other $WCkey, $SCkey so,

I tried to do following,
CODE

if ($WCkey eq undef && $SCkey eq undef)
{
         --- Do this
}

if ($WCkey ~~ undef && $SCkey ~~ undef)
{
         --- Do this
}


but both of these won't work, Any one have any suggestion????

Cheers

User is offlineProfile CardPM
+Quote Post


dsherohman

RE: Checking Undef

23 Jun, 2009 - 04:43 AM
Post #2

D.I.C Head
**

Joined: 29 Mar, 2009
Posts: 184



Thanked: 35 times
My Contributions
You generally want to use the "defined" operator rather than testing equality with undef:
CODE

if (!defined($WCkey) && !defined($SCkey))
{
         --- Do this
}

or
CODE

if (!(defined $WCkey || defined $SCkey))
{
         --- Do this
}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 12:10AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month