Here's an error that I very nearly made recently, simplified down to the bare (and rather trivial-looking) essentials:
for($i = 0; $i < 10; $i++) { &foo(); } # foo: print the first three positive integers sub foo { for($i = 1; $i <= 3; $i++) { print $i; } print "\n"; }
Uh, not good.
The problem was coming back to Perl after spending a lot of time writing PHP code, where variables inside functions are locally scoped by default. This story has a happy ending: my long-standing habit of using strict immediately caught the error, and saved me quite a bit of debugging time.
It occurs to me that this example might be useful when you're trying to convince people, especially ex-PHP types, that strict is good.
--
:wq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Implicit context conversion error, brain.pl line 666
by Juerd (Abbot) on Apr 02, 2002 at 18:34 UTC | |
|
Re: Implicit context conversion error, brain.pl line 666
by drewbie (Chaplain) on Apr 03, 2002 at 14:57 UTC | |
by FoxtrotUniform (Prior) on Apr 03, 2002 at 15:07 UTC | |
by drewbie (Chaplain) on Apr 03, 2002 at 15:25 UTC |