Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: if statement question

by nithins (Sexton)
on Dec 14, 2012 at 06:57 UTC ( #1008783=note: print w/ replies, xml ) Need Help??


in reply to if statement question

use strict; ## scalar has not been initialized here the value in $result is undef my $result; print "hi" if ($result); ### scalar has been initialized and the value here is 12 $result = 12; print $result if($result);

In 1st ,if condition looks for the value of a variable "$result" in this case its just declared its not been initialized hence if is evaluated as false and doesn't print "Hi"

In second, if condition looks for the value of a variable, its present & value is 12 , then if is evaluated as true and it print's "hi".


Comment on Re: if statement question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-19 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls