On Mon, 29 Jul 2002 19:39:35 +1000
scsijon-tpg
Simple Questions (I hope):
How do i find out what perl modules have already been installed and ?loaded on a system?
First make sure he has the right perl interpreter on the first line. Second, make sure the script isn't a dos file, check the line endings. There are a couple of ways to do it, depending on your needs. Try these two: #find-all-modules.pl #################################################### #!/usr/bin/perl use File::Find ; for (@INC) { find(\&modules,$_) ; } sub modules { if (-d && /^[a-z]/) { $File::Find::prune = 1 ; return } return unless /\.pm$/ ; my $fullPath = "$File::Find::dir/$_"; $fullPath =~ s!\.pm$!!; $fullPath =~ s#/(\w+)$#::$1# ; print "$fullPath \n"; } ##################################################### #installed-modules.pl ############################################################### #!/usr/bin/perl use ExtUtils::Installed; my $instmod = ExtUtils::Installed->new(); foreach my $module ($instmod->modules()) { my $version = $instmod->version($module) || "???"; print "$module -- $version\n"; } #for a oneliner #perl -MExtUtils::Installed -le 'print for ExtUtils::Installed->new->modules' ############################################################## -- use Perl; #powerful programmable prestidigitation