in reply to Re: strange scope
in thread strange scope
If you use strict and warnings (or at least warnings), you should get a warning like:
Found = in conditional, should be == at scope_test.pl line 5.
For example, in the following code:
use strict; use warnings; while (my $y = 1) { $y = 0; print "hello (y = $y)\n"; }
You will get the warning about "= in conditional".
It's also interesting to note that this test program, which is essentially equivalent to:
use strict; use warnings; my $y = 0; while ($y = 1) { $y = 0; print "hello (y = $y)\n"; }
will never terminate, even though $y is set to zero each time, because it's set to 1 immediately before the condition of the while statement is evaluated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: strange scope
by jasonk (Parson) on May 23, 2007 at 14:29 UTC | |
|
Re^3: strange scope
by Beechbone (Friar) on May 23, 2007 at 15:31 UTC | |
|
Re^3: strange scope
by blazar (Canon) on May 23, 2007 at 09:16 UTC |