in reply to difference between 'if (condition) { expression;}' and 'expression if (condition)'
In your first example, $var is declared inside the if block, but exists ONLY within that block. Since it's undefined when program_flow encounters the print statement, strict pumps out the error.
On the other hand, in your example 2, "my $var" is in scope throughout the code you show.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: difference between 'if (condition) { expression;}' and 'expression if (condition)'
by xdg (Monsignor) on Mar 22, 2006 at 14:37 UTC | |
by ranjan_jajodia (Monk) on Mar 22, 2006 at 14:40 UTC | |
|
Re^2: difference between 'if (condition) { expression;}' and 'expression if (condition)'
by diotalevi (Canon) on Mar 22, 2006 at 14:36 UTC | |
|
Re^2: difference between 'if (condition) { expression;}' and 'expression if (condition)'
by ranjan_jajodia (Monk) on Mar 22, 2006 at 14:38 UTC |