> I have a variable in my script that is taking on a value
> from a hash:
>
>    my $myvar = $hashname{$key}{$subkey}{in};
>
> Where $hashname{$key}{$subkey}{in} may have never been
> assigned a value.  I later try to use $myvar (I use
> strict and warnings), and get an error "Use of
> uninitialized value in ..."
> 
> I want to test $myvar immediately after the assignment
> to see if it is uninitialized.  I then get the same
> error on my conditional.
> 
> I have tried a few things, checked the Camel book and the
> Cookbook, and tried to find something with my rudimentary
> knowledge of perldoc.  I'm guessing/hoping that there is
> a test for uninitialized.  Please point me towards the
> correct answer in any of the listed resources.

if ($myvar != undef) {...}
if (defined $myvar)  {...}

perldoc -f perlvar    # Obviously
Camel page 58, 697 (look up the index, like me!)
Cookbook page 1-3  (I guess it's knowing where to start ;)

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to