Every non-initialized variable is not defined.
UPDATE:DB<1> print $a // "undef" undef DB<2> my $a;print $a // "undef" undef DB<3> our $a;print $a // "undef" undef DB<4> $a=1;print $a // "undef" 1
And in most cases accessing an undefined variable will be caught under use warning;.
DB<1> print $a DB<2> use warnings; print $a Use of uninitialized value $a in print at (eval 6)[/usr/share/perl/5.1 +0/perl5db.pl:638] line 2. .. DB<3> use warnings; $a=undef;print $a Use of uninitialized value $a in print at (eval 9)[/usr/share/perl/5.1 +0/perl5db.pl:638] line 2. .. DB<4> print $a++ 0
Notable exceptions of this warnings are some altering operators like ".=" and "++" and auto-vivication in hashes and arrays.¹
Cheers Rolf
1) anything else?
... of course boolean context including the defined operator won't throw a warning.
In reply to Re^2: Perl Style: Is initializing variables considered taboo?
by LanX
in thread Perl Style: Is initializing variables considered taboo?
by ait
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |