Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: scalar values assignment

by nvivek (Vicar)
on Apr 09, 2010 at 13:05 UTC ( #833787=note: print w/ replies, xml ) Need Help??


in reply to scalar values assignment

If you want to check whether that particular scalar is defined or not.You can simply use it in the if statement as follows.

if($scalar) { statements } else { statements }
If you want to check if it is undef,then you can use unless or simple else for the above if statement. For inverse of if,you can also use unless.


Comment on Re: scalar values assignment
Download Code
Re^2: scalar values assignment
by almut (Canon) on Apr 09, 2010 at 13:19 UTC
    if($scalar) ...

    Strictly speaking, that would test whether $scalar is true, not whether it's defined. 0 or "", for example, evaluate to false, but are considered "defined".  Test defined instead.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-07-11 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (218 votes), past polls