note
simonflk
<p>This is a nice trick, but it won't work if the script or or any modules that are loaded do a <tt>use lib</tt> or <tt>unshift @INC</tt></p>
<p>Something like this should work, as long as require is not overriden elsewhere:</p>
<code>
package ShowDependencies;
use strict;
*CORE::GLOBAL::require = \&show_require;
sub show_require (;$) {
my $module = shift;
print STDERR $module, $/;
my $retval = eval "CORE::require( $module )";
die $@ if $@;
return $retval;
}
1;
</code>
<p>There is also a module ([cpan://Module::Dependency]) on the CPAN that builds a list of dependencies.</p>
<b>update:</b> added use strict
<!--sig-->
<p>-- simonflk</p>
<!--/sig-->
203148
203148