Re: Print out modules used during runtime?



"Paul Lalli" <mritty@xxxxxxxxx> wrote:

Omar Zakaria wrote:
Hello, all. I was wondering if there's a way, without downloading any
special modules, or packages, to have a perl script print out the list
of packages or modules it imported (i.e. anything I "use"'d or
"require"'d).

%INC is probably what you're looking for. It keeps a list of all
modules used/required as keys, with the values being the paths to
those modules. Note, however, that %INC will have not only the modules
your script specifically used, but also those modules used by a module
your script used:

$ perl -e' use CGI; print "$_ => $INC{$_}\n" for keys %INC;'
warnings/register.pm =>
/opt2/Perl5_8_4/lib/perl5/5.8.4/warnings/register.pm
Carp.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/Carp.pm
vars.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/vars.pm
strict.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/strict.pm
Exporter.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/Exporter.pm
constant.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/constant.pm
warnings.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/warnings.pm
CGI/Util.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/CGI/Util.pm
overload.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/overload.pm
CGI.pm => /opt2/Perl5_8_4/lib/perl5/5.8.4/CGI.pm

See perldoc perlvar for more information about %INC.

I think the problem is:

#Insert awesome perl program here

and the fact that it's an exe.

http://www.die.net/doc/linux/man/man1/strace.1.html

I am sure there is something similar for Windows (tracing which files are
opened by an exe).

--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
.



Relevant Pages

  • Re: Print out modules used during runtime?
    ... any special modules, or packages, to have a perl script print out ... the list of packages or modules it imported (i.e. anything I "use"'d ... modules your script specifically used, but also those modules used by ... and the fact that it's an exe. ...
    (comp.lang.perl.misc)
  • Re: Broken perl
    ... that perl itself and several other packages cannot be upgraded because ... the system can't find some perl files. ... upgrade. ... that script fails and apt aborts the whole operation, ...
    (Debian-User)
  • Re: A few qs on python files.
    ... There are packages that can convert your script into an ... the interpreter. ... When the .exe is executed, ...
    (comp.lang.python)
  • Re: Parameters in command line
    ... >> Read a bit more about PAR and pp and then you understand. ... Perl etc. ... most people it just looks like an exe. ... want to call from script an exe, even if one I have access to ...
    (comp.lang.perl.misc)
  • 2005-10-23 [de.comp.lang.perl.cgi] FAQ
    ... Programmiersprache Perl in CGI-Scripten. ... Wo gibt es Dokumentation über Perl und CGI? ... Hilfe zum Programm perldoc kann man mit 'perldoc perldoc' ... Mein Script läuft nicht bei meinem Provider. ...
    (de.comp.lang.perl.cgi)