in reply to RE: Benchmark.pm's scoping behavior
in thread Benchmark.pm's scoping behavior

Overall, nice discussion. To comment on one point you raised, though... you wrote:
sub error { print $data; # oops, doesn't work! }
Well, it *does* work. If you try it, you'll see that it works just fine, because it's a lexical variable... lexical to the scope of the file. And the error sub is defined in the file, so $data is visible there.

That's not to say that it's recommended, of course, because it can definitely cause you problems. Particularly when using mod_perl. You'll get the dreaded "variable may not stay shared" message, because essentially you've defined a closure.

That said, though, good points.

Replies are listed 'Best First'.
... mod_perl
by Aighearach (Initiate) on Jun 21, 2000 at 09:23 UTC
    As it turns out, almost all my code has to run under mod_perl...