in reply to Can I see "requires"?
As others have already said, %INC.
However, note that it's quite possible to directly manipulate this hash:
use 5.010; # Trick perl into thinking that Moose.pm has # already been required. $INC{'Moose.pm'} = '/tmp/Moose.pm'; # Require it for real. But perl does nothing! require Moose; # Perl thinks Moose is loaded. say "Moose is loaded" if $INC{'Moose.pm'}; # But it isn't really, so we don't know VERSION. say 'Moose version:', Moose->VERSION;
I have in the past had cause to directly manipulate %INC. A module I was using wanted to be passed the name of plugin module to use. It would require that plugin and then use it. However, I wanted to define the plugin inline in my code, a la
{ package My::Plugin; ... } Something::That::Uses::Plugins->load_plugin('My::Plugin');
But this caused Something::That::Uses::Plugins to attempt to require the non-existent file "My/Plugin.pm". So...
{ package My::Plugin; ... $INC{'My/Plugin.pm'} = __FILE__; } Something::That::Uses::Plugins->load_plugin('My::Plugin');
And everybody's happy.
But anyway, my point is that although %INC should give you the information you want, it can't necessarily be trusted 100%.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can I see "requires"?
by JavaFan (Canon) on Mar 08, 2012 at 16:21 UTC | |
by Anonymous Monk on Jun 28, 2012 at 01:18 UTC |