On Mon, Mar 17, 2008 at 6:51 AM,  <[EMAIL PROTECTED]> wrote:
> How is it possible to initialize variable using 0 or '' and not having
>  undef warning later on using them?
snip

Well, you can say

my $var = 0;

but that doesn't prevent the variable from being set to undef later,
so if it is possible for the variable to be undef you should guard
against it with the defined function (or, if you have Perl 5.10, the
// operator):

print "\$var is ", (defined $var ? $var : "undef"), "\n"; #Perl 5.8 and below

say "\$var is ", $var // "undef"; #Perl 5.10


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to