http://qs321.pair.com?node_id=1087888


in reply to disabling unnecessary perl modules

Hey, in the future can you not put an entire script in Perlmonks? Wait until someone asks you for a specific piece of code rather than dump the whole thing.

The answer to your question is going to be rather messy:

# cat foo.pl # ----------- #!/usr/bin/perl -w use strict; use CGI; use LWP::Simple; 1; strace perl foo.pl 2> foo.pl.strace perl -ne 'if(m/(\S+\.pm)/){print qq|$1\n|}' foo.pl.strace|sort|uniq|ca +t -n

Produces (in short):

... 149 stat64("/usr/lib/perl5/site_perl/5.10.0/LWP.pm 150 stat64("/usr/lib/perl5/site_perl/5.10.0/LWP/Protocol.pm 151 stat64("/usr/lib/perl5/site_perl/5.10.0/LWP/Simple.pm 152 stat64("/usr/lib/perl5/site_perl/5.10.0/LWP/UserAgent.pm 153 stat64("/usr/lib/perl5/site_perl/5.10.0/URI/Escape.pm 154 stat64("/usr/lib/perl5/site_perl/5.10.0/URI.pm 155 stat64("/usr/lib/perl5/vendor_perl/5.10.0/Encode/ConfigLocal +.pm 156 stat64("/usr/lib/perl5/vendor_perl/5.10.0/i586-linux-thread- +multi/Encode/ConfigLocal.pm 157 stat64("/usr/lib/perl5/vendor_perl/5.10.0/i586-linux-thread- +multi/Log/Agent.pm 158 stat64("/usr/lib/perl5/vendor_perl/5.10.0/Log/Agent.pm 159 stat64("/usr/lib/perl5/vendor_perl/Encode/ConfigLocal.pm 160 stat64("/usr/lib/perl5/vendor_perl/Log/Agent.pm 161 XSLoader.pm

So, for a script that does nothing interesting and only uses two modules Perl actually checks for the presence of 161 modules. Looking at %INC only shows 37 elements for the same script, so I'm inclined to think that strace is giving me the bigger picture. Figuring out which modules you can live without should be a chore. I think you can save yourself the headache and just put all of the modules a script needs in a PAR archive and reference that.

Celebrate Intellectual Diversity