NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Perl::Critic's RequireExplicitPackage Policy (Score:1)
In file Foo.pm:
sub frobulator{ print shift; }
our $SHIZZLE = 42;
package Foo;
sub foo { return main::frobulator( @_ ) }
In file my_script.pl:
use Foo;
Foo::foo( $SHIZZLE );
Since $SHIZZLE and &frobulator are declared before the package statement in Foo.pm, they wind up in the caller's namespace (main). So Foo::foo will only work if it is loaded by main. And when my_script starts loading other libraries that might also load Foo, then it become a big steaming pile.
I trully hope that sane developers will never encounter this problem. But I'm frequently surprised how much insanity there is in the world :)
Reply to This