Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

RE: Baby Steps

by flyfishin (Monk)
on Jun 22, 2000 at 23:47 UTC ( #19495=note: print w/replies, xml ) Need Help??


in reply to Baby Steps "if" behavior?

If I remember correctly 0, null string, and empty string are all false answers. However, 0 and empty string are defined answers. $kaka ne "" checks to see if $kaka is equal to the empty string. Whereas defined $kaka checks to see if $kaka is something other than 0, null, or empty. I also think there are some differences for defined and exists. I think exists only applies to hash values. I know this isn't a complete answer but it gets you pointed in the right direction, I hope. Check in perlfunc for more complete answers.

Update:
Oops. You can uses exists to check on array elements. Next time I'll read perlfunc before shooting off with the fingers.

Replies are listed 'Best First'.
RE: RE: Baby Steps
by sean (Beadle) on Jun 23, 2000 at 04:04 UTC
    Well... defined $kaka actually checks to see if $kaka is defined at ALL. something that is defined as zero, null, or empty is still defined.
    sean@anticharm:~$ perl -e 'print "defined!\n" if defined $foo' sean@anticharm:~$ perl -we '$foo = 0; print "defined!\n" if defined $f +oo' defined! sean@anticharm:~$ perl -we '$foo = ""; print "defined!\n" if defined $ +foo' defined!
    As far as I am aware, once you define something you must use undef (or assign it the value of something undefined: undef $baz; $foo=$baz;) if you want it to be undefined again.
RE:(2) Baby Steps (exists on array)
by Russ (Deacon) on Jun 23, 2000 at 03:15 UTC
    Using exists on an array is a new feature in 5.6

    For those of us too lazy (busy) to upgrade, you were right. :-)

    Russ

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2021-01-21 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?