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

Re: Uninitialized value

by zzspectrez (Hermit)
on May 10, 2002 at 16:41 UTC ( [id://165707]=note: print w/replies, xml ) Need Help??


in reply to Uninitialized value

> my $junk; > print 1+$junk;
> Returns an unitialized value warning, as expected.
> print 1+($junk ? $junk : 0);
> Returns 1, no warning.

This should not return a warning. This statement says, if $junk is true then return $junk add 1 to it and print the result. If $junk is false, which is the case since it is undefined, then return 0 and add 1 to it and print the result.
I think what you meant is if you wrote it like:

print 1+ ( $junk ? 0 : $junk);
Then it will return a warning if $junk is undefined.

zzspectrez

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-23 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found