in reply to discovering installed packages
find out whats there and what needs to be added
This is a FAQ (or part of it is, anyway): perlfaq3, "How do I find which modules are installed on my system?"
Nonetheless, it has been asked many times and because TMTOWTDI there are nearly as many different answers. Super Search is your friend. The following results were found using this search:
Additional links can be found within those threads. Lastly, the section in Tutorials entitled Modules: How to Create, Install, and Use may also be of some use.Here are two example scripts that I found floating around my hard drive. The first uses File::Find to locate installed modules (some may advocate the File::Find::Rule interface instead) and the second uses Module::Info to obtain the version and path information for each module. Once you have that information, you can compare it to your list of dependencies.
Example of File::Find
use strict; use warnings; use File::Find; my $outfile = 'installed_mods.txt'; open( OUTFILE, '>', $outfile ) or die "error opening $outfile: $!\n"; 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 OUTFILE "$fullPath\n"; }
Example of Module::Info
use strict; use warnings; use Module::Info; my @mods = Module::Info->all_installed( 'Bit::Vector' ); foreach my $mod ( @mods ) { print join( "\n ", $mod->name, $mod->version, $mod->inc_dir, $mod->file, $mod->is_core ); }
Update: Added Super Search results
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: discovering installed packages
by ethrbunny (Monk) on Jun 05, 2007 at 16:05 UTC | |
by FunkyMonk (Bishop) on Jun 05, 2007 at 21:17 UTC |