View Full Version : Function in Perl similar to phpinfo() from PHP
MagnuM
06-17-2004, 07:50 AM
Hello, I don't have experience in Perl language, but I want to know some information, like Perl version or Perl installed modules on my server. I supose it need to be something like the phpinfo() function available in PHP.
Can you give me any hints?
sander815
06-17-2004, 08:02 AM
perldiver.cgi can do thathttp://www.scriptsolutions.com/programs/free/perldiver/
MagnuM
06-17-2004, 08:37 AM
Did you have it?
So do not have to register myself there.
sander815
06-17-2004, 12:40 PM
just reg with a yahoo mail, its simple...
Webcart
06-22-2004, 05:58 PM
The following script will list Perl modules installed on your server:
#!/usr/local/bin/perl -w
use strict;
use IO::Dir;
use ExtUtils::Packlist;
use ExtUtils::Installed;
sub emptydir($) {
my ($dir) = @_;
my $dh = IO::Dir->new($dir) || return(0);
my @count = $dh->read();
$dh->close();
return(@count == 2 ? 1 : 0);
}
# Find all the installed packages
print("Finding all installed modules...\n");
my $installed = ExtUtils::Installed->new();
foreach my $module (grep(!/^Perl$/, $installed->modules())) {
my $version = $installed->version($module) || "???";
print("Found module $module Version $version\n");
next;
print("Do you want to delete $module? [n] ");
my $r = <STDIN>; chomp($r);
if ($r && $r =~ /^y/i) {
# Remove all the files
foreach my $file (sort($installed->files($module))) {
print("rm $file\n");
unlink($file);
}
my $pf = $installed->packlist($module)->packlist_file();
print("rm $pf\n");
unlink($pf);
foreach my $dir (sort($installed->directory_tree($module))) {
if (emptydir($dir)) {
print("rmdir $dir\n");
rmdir($dir);
}
}
}
}
If you comment out "next" command, it will also allow you to remove modules.
nobaloney
06-23-2004, 11:52 AM
Thanks, Webcart.
Very nice.
Note that we had to, and some other admins may have to, change the path to the perl interpreter in the first line.
We changed it as follows:
!/usr/bin/perl -w
Is it your script?
Is it copyright? Covered under any license?
I'm thinking about modifying it to show output in html, and also removing the code that allows you to delete modules, and make it web accessible.
Can you see any problem with that?
Jeff
Webcart
06-23-2004, 12:11 PM
The script is taken from http://www.perldoc.com/ , so I don't think there are any license issues.
As far as I recall, I didn't do any code modifications beside adding "NEXT" line which converted module removal script into a script that can only list installed modules.
In any case, I wouldn't mind :)
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.