![]() |
Find & Checking Modules Used by Perl Programs
Say you have a couple of Perl programs and you would like to know what modules are used by the programs, and may be you would also like to know what are the module versions and if they exists or not.
Here is a combination of common commands to list and print module version, and print a message if the module does not exists. Code:
egrep '^[\s\t]*use[ ]+[a-zA-Z:]' *.pl|cut -d ' ' -f 2|cut -d ';' -f 1|sort --unique|xargs -n 1 -I % perl -e 'eval {require %;print "% => ", $%::VERSION,"\n";}; print "\033[31mmissing %\033[0m\n" if($@);'Code:
egrep -R '^[\s\t]*use[ ]+[a-zA-Z:]' *.pl|cut -d ' ' -f 2|cut -d ';' -f 1|sort --unique|xargs -n 1 -I % perl -e 'eval {require %;print "% => ", $%::VERSION,"\n";}; print "\033[31mmissing %\033[0m\n" if($@);'Code:
[root@pradeep:/var/www/cgi-bin] egrep -R '^[\s\t]*use[ ]+[a-zA-Z:]' *|cut -d ' ' -f 2|cut -d ';' -f 1|sort --unique|xargs -n 1 -I % perl -e 'eval {require %;print "% => ", $%::VERSION,"\n";}; print "\033[31mmissing %\033[0m\n" if($@);' |
Re: Find & Checking Modules Used by Perl Programs
ExtUtils::Installed
this module is used to show all installed distributions, sample code: Code:
use ExtUtils::Installed;- Example: ------- Code:
use Data::Dumper; |
Re: Find & Checking Modules Used by Perl Programs
I'm trying to figure out how to automatically list all the modules used by
a particular program. Try this, foreach (sort keys %INC) {print "$_\n"} This will give default modules used by a particular program. If you include any module other than default things that also will include in your INC hash. |
Re: Find & Checking Modules Used by Perl Programs
*{$glob}{PACKAGE} , *{$glob}{NAME}, these are all built in variables used to find the packages used in the current Perl program
|
| All times are GMT +5.5. The time now is 18:01. |