perl模块的安装,查询

perl模块的安装,查询


linux下cpan安装:
# perl -MCPAN -e shell             // 一路回车配置cpan,个别地方需要输入
cpan> install 模块名

以后安装就可以:
# perl -MCPAN -e 'install 模块名'

windows下ActivePerl安装:
直接用Perl Packge Manager图形安装就可以了


查询安装好的模块:
当你需要使用模个模块,不知道是不是安装了的时候,可以使用下面的命令查看:
# perldoc perllocal
有类似下面的东西出来:
PERLLOCAL(1) User Contributed Perl Documentation PERLLOCAL(1)

Thu Feb 18 11:24:54 2010: "Module" Digest::HMAC

・ "installed into: /usr/lib/perl5/site_perl/5.8.8"

・ "LINKTYPE: dynamic"

・ "VERSION: 1.02"

・ "EXE_FILES: "

Thu Feb 18 11:24:58 2010: "Module" Net::IP

・ "installed into: /usr/lib/perl5/site_perl/5.8.8"

・ "LINKTYPE: dynamic"

・ "VERSION: 1.25"

・ "EXE_FILES: ipcount iptab"

Thu Feb 18 11:29:05 2010: "Module" Config::IniFiles

・ "installed into: /usr/lib/perl5/site_perl/5.8.8"

・ "LINKTYPE: dynamic"

・ "VERSION: 2.56"

・ "EXE_FILES: "



另外还可以使用下面的命令:
# perl -MConfig::IniFiles -e 1
如果不报错就是已经安装了.

shell下直接输入下面命令,可以找到所有已经安装的模块.路径
# find `perl -e 'print "@INC"'` -name '*.pm' -print



或者用这个脚本:  很详细.
http://cpansearch.perl.org/src/MLFISHER/pmtools-1.01/pminst
#!/usr/bin/env perl
# pminst -- find modules whose names match this pattern
# [email protected]

BEGIN { $^W = 1 }

use Getopt::Std qw(getopts);
use File::Find;

getopts('ls') || die "bad usage";

if (@ARGV == 0) {
        @ARGV = ('.');
}    

die "usage: $0 [-l] [-s] pattern\n" unless @ARGV == 1;

$pattern = shift();
$pattern =~ s,::,/,g;

no lib '.';

use vars qw($opt_l $opt_s);

for $startdir (@INC) {    
        find(\&wanted, $startdir);
}

sub wanted {
        if (-d && /^[a-z]/) {    
  # this is so we don't go down site_perl etc too early
  $File::Find::prune = 1;
  return;
        }
        return unless /\.pm$/;
        local $_ = $File::Find::name;
        ($tmpname = $_) =~ s{^\Q$startdir/}{};
        return unless $tmpname =~ /$pattern/o;

        if ($opt_l) {    
  s{^(\Q$startdir\E)/}{$1 } if $opt_s;
        }    
        else {
  s{^\Q$startdir/}{};    
  s/\.pm$//;
  s{/}{::}g;
  print "$startdir " if $opt_s;
        }    

        print $_, "\n";
}    

__END__

=head1 NAME

pminst - find modules whose names match this pattern

=head1 SYNOPSIS

pminst [B<-s>] [B<-l>] [I<pattern>]

=head1 DESCRIPTION

Without argumnets, show the names of all installed modules.    Given a
pattern, show all module names that match it.    The B<-l> flag will show
the full pathname.    The B<-s> flag will separate the base directory from
@INC from the module portion itself.


=head1 EXAMPLES

        $ pminst
        (lists all installed modules)

        $ pminst Carp
        CGI::Carp
        Carp

        $ pminst ^IO::
        IO::Socket::INET
        IO::Socket::UNIX
        IO::Select
        IO::Socket
        IO::Poll
        IO::Handle
        IO::Pipe
        IO::Seekable
        IO::Dir
        IO::File

        $ pminst '(?i)io'
        IO::Socket::INET
        IO::Socket::UNIX
        IO::Select
        IO::Socket
        IO::Poll
        IO::Handle
        IO::Pipe
        IO::Seekable
        IO::Dir
        IO::File
        IO
        Pod::Functions

    The -s flag provides output with the directory separated
    by a space:

        $ pminst -s | sort +1
        (lists all modules, sorted by name, but with where they    
         came from)

        $ oldperl -S pminst -s IO
        /usr/lib/perl5/i386-linux/5.00404 IO::File
        /usr/lib/perl5/i386-linux/5.00404 IO::Handle
        /usr/lib/perl5/i386-linux/5.00404 IO::Pipe
        /usr/lib/perl5/i386-linux/5.00404 IO::Seekable
        /usr/lib/perl5/i386-linux/5.00404 IO::Select
        /usr/lib/perl5/i386-linux/5.00404 IO::Socket
        /usr/lib/perl5/i386-linux/5.00404 IO
        /usr/lib/perl5/site_perl LWP::IO
        /usr/lib/perl5/site_perl LWP::TkIO
        /usr/lib/perl5/site_perl Tk::HTML::IO
        /usr/lib/perl5/site_perl Tk::IO
        /usr/lib/perl5/site_perl IO::Stringy
        /usr/lib/perl5/site_perl IO::Wrap
        /usr/lib/perl5/site_perl IO::ScalarArray
        /usr/lib/perl5/site_perl IO::Scalar
        /usr/lib/perl5/site_perl IO::Lines
        /usr/lib/perl5/site_perl IO::WrapTie
        /usr/lib/perl5/site_perl IO::AtomicFile

    The -l flag gives full paths:

        $ filsperl -S pminst -l Thread
        /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Queue.pm
        /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Semaphore.pm
        /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Signal.pm
        /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Specific.pm
        /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm

=head1 AUTHOR and COPYRIGHT

Copyright (c) 1999 Tom Christiansen

This is free software.    You may modify it and distribute it    
under Perl's Artistic Licence.    Modified versions must be
clearly indicated.



最后一个脚本,是查找你安装的所有第三方模块及其版本号:
#!/usr/bin/perl    
use strict;
use ExtUtils::Installed;

my $inst= ExtUtils::Installed->new();    
my @modules = $inst->modules();    

foreach(@modules)
{
                my $ver = $inst->version($_) || "???";    
                printf("%-12s --    %s\n", $_, $ver);
}
exit 0;





windows下还是那个东西,图形的.

你可能感兴趣的:(职场,查询,perl,休闲,perl模块的安装)