in reply to Check your wits
That's a classic "gotcha" in my book. That's one reason why I almost always write such code as:
{ my @values; BEGIN { @values = ( 1 .. 3 ); } sub _test { # ... } }
or, especially if the code is going into the main script for a mod_perl Apache::Registry page:
BEGIN { my @values = ( 1 .. 3 ); sub _test { # ... } }
Actually, that makes me wonder why I've been using the first form lately. I should switch back to the second form. Thanks for reminding me.
Oh, and to be extra clear, yes, it is easy to get caught by this problem (which is why I have a "practice" for preventing it).
- tye
|
|---|