www.polyteknique.net Annuaire d'URL géographique !

.:: PLAN :: CV :: CONTACT :: MOTEUR :: STATS :: BILLETS :: NNTP :: IRC ::.
Navigation : DEVELOPPEMENT > PERL
CONNAITRE LES MODULES PERL D'UNE MACHINE
Voici un script pratique pour lister les modules PERL installés sur la machine exécutant le script.
www.polyteknique.netALORS VOICI :)
#!/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>";
www.polyteknique.netLES LIENS :
MERCI A THIERRY POUR CE BOUT DE CODE : http://pretty-rss.snyke.com

Rédigé le : 2004-12-29 21:48:51
Admin - 2003-2008 @ PolyTek~>DeeZigN - 83954 visites - Contact
Chargée en 0.08 sec. - sans cache (10 requètes) - 38.103.63.16 - PhP : 4.4.4
Valid XHTML 1.0 ! Debian GNU/Linux est un système d'exploitation libre Valid CSS !