in reply to Re: Use of uninitialized value errors
in thread Use of uninitialized value errors
Nope. Perl forgives you if you simply test or assign a bare uninitialized variable in a conditional. Your code works for this reason -- no warning for "if ($var)". Going over your post, I think this is a case where you understand but just mis-stated your assertion.
Note:
#!/usr/bin/perl -w use strict; my $stuff; # No complaint here if ($stuff) { print "hello\n"; } # No complaint here if (my $stuff2 = $stuff) { print "hello\n"; } # But this interpolation causes a warning if (my $stuff3 = "$stuff") { print "hello\n"; } # This concatenation complains also if (my $newstuff = "new $stuff") { print "hello\n"; }
------------------------------------------------------------
"Perl is a mess
and that's good because the
problem space is also a mess." - Larry Wall
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Use of uninitialized value errors
by blackjudas (Pilgrim) on May 17, 2002 at 17:36 UTC |