in reply to 'require/use' scoping

It costs you nothing to test it out. Give it a whirl, see for yourself.

Some things to try (assuming Mod has something in it):
print "Mod loaded at 1" if %{Mod::}; require Mod; print "Mod loaded at 2" if %{Mod::};
print "Mod loaded at 1" if %{Mod::}; use Mod; print "Mod loaded at 2" if %{Mod::};
print "Mod loaded at 1" if %{Mod::}; sub require_it { require Mod; } print "Mod loaded at 2" if %{Mod::}; require_it(); print "Mod loaded at 3" if %{Mod::};
print "Mod loaded at 1" if %{Mod::}; sub use_it { use Mod; } print "Mod loaded at 2" if %{Mod::}; use_it(); print "Mod loaded at 3" if %{Mod::};
As for the documentation, you could always try perldoc, pm super search, google, etc.

And in case you realy want to know whats realy happening, the perl source code is freely available.

Replies are listed 'Best First'.
Re^2: 'require/use' scoping
by gnum.prul (Initiate) on Jan 29, 2008 at 15:04 UTC
    Yes, I really want to know what's happening, i.e. I'd like to know how exactly requiring is different from eval `cat mod.pm`; as perldoc contains numerous code snippets showing how require works based on eval. I guess the source is the answer...