I see, that's a really bad example and I can see why it would confuse.
Variables in perl don't have a true "undefined state" like say C might.
Because of autovivification, *all* variables are in a state of potential
existence. Once u reference a variable, it comes into existence with the
undefined value. defined() see's if a variable has the undef value or
something else, including null. So in ur example below it should be "a's
value is not undef" not "a has a value". In perl "defined" means "has
anything every been assigned to x".
At 07:27 AM 7/22/05 -0700, lorid wrote:
>you are right about I should test for null or length of value instead but
>I found the place where I got information that says that to be defined a
>var must have a value:
>Beginnng Perl by Simon Cozens pg 123:
>
>"We can test if a variable is defined by.......
>my $a;
>my $b;
>$b = 10;
>if (defined $a){
> print "a has a value.\n";
>}
>if (defined $b){
> print "b has a value.\n";
>}
>#only prints b has a value
--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede males"
00000100
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs