in reply to conditional definition of variables
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.unless ( defined $var) { my $var = "zzz\n" }
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,
rir
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: conditional definition of variables
by JadeNB (Chaplain) on Aug 26, 2008 at 23:20 UTC |