#!/usr/bin/perl
# Description :
# This script lists available perl modules on the host running the script.
# Thierry, http://pretty-rss.snyke.com
use strict;
use File::Find;
# print script and quit if called with param
if ($ENV{"QUERY_STRING"} eq 'source'){
print "Content-type: text/plain\n\n";
open my $file, '<', $0;
while (<$file>) {print;}
close $file;
exit;
}
# Do the job
my @mods_name; # result data
my @mods_path; # result data
sub wanted {
my $mod = $_;
my $mod_path = $File::Find::name;
if ($mod =~ /\.pm$/) {
push (@mods_name, $mod) if ! grep(/$mod/,@mods_name);
push (@mods_path, $mod_path) if ! grep(/$mod_path/,@mods_path);
}
}
find(\&wanted, @INC);
# end of job
# Now the output the stuff
print "Content-type: text/html\n\n<html><body><pre>";
print qq[
Available perl modules
======================
(Use parameter 'source' to view source: http://..../this_script?source)
----------------------------------------------------------------------
Server address: $ENV{"SERVER_ADDR"}
----------------------------------------------------------------------
Perl Version : ];
print $];
print qq[
----------------------------------------------------------------------
Include directories (\@INC)
----------------------------------------------------------------------
];
foreach (@INC) {print "$_\n";}
print qq[
----------------------------------------------------------------------
Modules (full names) :
----------------------------------------------------------------------
];
foreach (sort(@mods_path)) {print "$_\n";}
print qq[
----------------------------------------------------------------------
Modules (short names) :
----------------------------------------------------------------------
];
foreach (sort(@mods_name)) {print "$_\n";}
print "</pre></body></html>";