in reply to Re^2: detecting an undefined variable
in thread detecting an undefined variable
no strict 'vars'; no warnings 'once';
Without strict, if a variable '$state' is not already declared, perl will automatically declare a package variable '$state'. Of course this variable would not be defined so perl would assign your '1' to $mystate. This could lead to a very subtle bug if in the future you ever tried to declare a lexical variable '$state'. It is legal to have two variables with the same name. Hard to tell which one perl will think you mean.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: detecting an undefined variable
by AnomalousMonk (Archbishop) on Sep 25, 2019 at 21:11 UTC |