Don't ask to ask, just ask | |
PerlMonks |
Re: conditional definition of variablesby rir (Vicar) |
on Aug 26, 2008 at 15:24 UTC ( [id://706922]=note: print w/replies, xml ) | Need Help?? |
my $var="zzz\n" unless defined($var)
This is the problem; the behavior of a my declaration in a statement with a conditional modifier is undefined. This is documented in perldoc perlsyn. Convert that to an unless statement: and you will get predictable behavior, but, probably, not what you want. I don't know what you are trying to do, but you might consider using a hash to hold the set of variables that may or may not exist.
Be well,
In Section
Seekers of Perl Wisdom
|
|