in reply to Benchmark.pm's scoping behavior
Now use that in your other file:package R; my $R = 10;
Run it, and what do we get? Nothing. Well, if you have warnings on, you get some warnings about unitialized values, and names only being used once.use R; package main; my $subcode = "sub { local \$_; package R; print $R }"; my $subref = eval $subcode; &$subref;
The point, though, is that one we've moved the declaration of $R as a lexical variable into a separate file, your code no longer does what you thought it would. Which means that it wasn't doing what you thought it was, in the first place. :)
|
|---|