Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl question

Status
Not open for further replies.

nyck

Technical User
Joined
Mar 10, 2004
Messages
447
Location
GB
hello,

i'm totally new to perl and was wondering if there is a way to tell what modules are installed within perl?
 
Did you look in the FAQ section? Specifically, look at faq219-5657.
 
almost the same as the answer for FAQ but printing result as HTML format
Code:
#!/usr/bin/perl    
# It creates a HTML table displaying all Perl Modules Installed
# Run on Windows and Unix.

use strict;
use File::Find;

my $count = 0;   
open( OUTFILE, ">modules.html" );

my (@mod, %done, $dir);
find(\&get, grep { -r and -d } @INC);
@mod = grep(!$done{$_}++, @mod);
foreach $dir (sort { length $b <=> length $a } @INC) {
   foreach (@mod) { next if s,^\Q$dir,,; }
}
print OUTFILE "Content-type: text/html\n\n";

print OUTFILE "<HTML><HEAD><TITLE>Installed Perl Modules</TITLE></HEAD><BODY bgcolor='#c0c0c0'>";
print OUTFILE "<h3 align='center'>Perl Modules Installed</h3>";

# list table heading
 print OUTFILE "<table border=1 bgcolor='#999999' align='center'>";
     print OUTFILE "<tr><th>Perl Module Number</th><th>Perl Module Name</th></tr>\n";

foreach (@mod) { s,^/(.*)\.pm$,$1,; s,/,::,g; 

print OUTFILE "<tr align='center'>";
print OUTFILE "<td>$count</td>";
print OUTFILE "<td>$_</td>";
print OUTFILE "</tr>\n";

$count++;
}

print OUTFILE "</table>"; 
print OUTFILE "Total : ($#mod modules!)\n\n";
sub get { /^.*\.pm$/ && /$ARGV[0]/i && push @mod, $File::Find::name; }

dmazzini
GSM System and Telecomm Consultant

 
hello,

cheers for these scripts!

i have now located the version of perl which has the required module i was after.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top