2013年2月23日 星期六

linux Perl 開發環境初使化工作



http://www.ncftp.com/download/

download & install ncftp-client

初使化 cpan ( Perl Module 安裝工具)

#cpan 
#cpan -h (說明)

cpan的使用方式

#cpan Module::Name



#cpan DBI

或 安裝 cpanm  ( Perl Module 安裝工具)

#curl -LO http://bit.ly/cpanm
#chmod +x cpanm
#cp cpanm /bin
#cpanm --help (說明)

#cpanm DBI

[root@centos63 tmp]# cpanm  DBIDBI is up to date. (1.623)

[root@centos63 tmp]# cpan DBI  CPAN: Storable loaded ok (v2.20)
Going to read '/root/.cpan/Metadata'
  Database was generated on Sat, 23 Feb 2013 14:29:04 GMT
DBI is up to date (1.623).

cpanp (perl Module 安裝工具 perl 5.10.xx 以後才支援)

#cpanp -i SVK

cpan> install CPANPLUS

[root@centos63 tmp]# cpanp
CPANPLUS::Shell::Default -- CPAN exploration and module installation (v0.9134)
*** Please report bugs to <bug-cpanplus@rt.cpan.org>.
*** Using CPANPLUS::Backend v0.9134. 
*** ReadLine support available (try 'i Term::ReadLine::Perl').
*** Type 'p' now to show start up log
Did you know...
    You can type 'h' for help and 'q' to exit
CPAN Terminal> h
[General]
    h | ?                  # display help
    q                      # exit
    e                      # exit and reload
    v                      # version information
[Search]
    a AUTHOR ...           # search by author(s)
    m MODULE ...           # search by module(s)
    f MODULE ...           # list all releases of a module
    o [ MODULE ... ]       # list installed module(s) that aren't up to date
    w                      # display the result of your last search again
[Operations]
    i MODULE | NUMBER ...  # install module(s), by name or by search number
    i URI | ...            # install module(s), by URI (ie http://foo.com/X.tgz)
    i DIR | ...            # install module(s), by path (ie ./Module-1.0)
    t MODULE | NUMBER ...  # test module(s), by name or by search number
    u MODULE | NUMBER ...  # uninstall module(s), by name or by search number
    d MODULE | NUMBER ...  # download module(s)
    l MODULE | NUMBER ...  # display detailed information about module(s)
    r MODULE | NUMBER ...  # display README files of module(s)
    c MODULE | NUMBER ...  # check for module report(s) from cpan-testers
    z MODULE | NUMBER ...  # extract module(s) and open command prompt in it
[Local Administration]
    b                      # write a bundle file for your configuration
    s program [OPT VALUE]  # set program locations for this session
    s conf    [OPT VALUE]  # set config options for this session
    s mirrors              # show currently selected mirrors
    s reconfigure          # reconfigure settings
    s selfupdate           # update your CPANPLUS install
    s save [user|system]   # save settings for this user or systemwide
    s edit [user|system]   # open configuration file in editor and reload
    ! EXPR                 # evaluate a perl statement
    p [FILE]               # print the error stack (optionally to a file)
    x                      # reload CPAN indices (purges cache)
    x --update_source      # reload CPAN indices, get fresh source files
[Common Options]
   i ... --skiptest        # skip tests
   i ... --force           # force all operations
   i ... --verbose         # run in verbose mode
[Plugins]
   /plugins                # list available plugins
   /? [PLUGIN NAME]        # show usage for (a particular) plugin(s)
CPAN Terminal>


reconfig cpan 的方法

cpan> o conf init


以前會使用 perlcc 去 compile 但那是在 perl 5.8.xx (CentOS Linux 5.xx) 的時代,
在 perl 5.10.xx (CentOS Linux 6.xx )以後,已由 pp 取代了原 perlcc 的功能!
使用方式

#pp -o test test.pl

[root@centos63 tmp]# perl -v
This is perl, v5.10.1 (*) built for i386-linux-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

[root@centos63 tmp]# pp -version
PAR Packager, version 1.014 (PAR version 1.007)
Copyright 2002-2009 by Audrey Tang <cpan@audreyt.org>
Neither this program nor the associated "parl" program impose any
licensing restrictions on files generated by their execution, in
accordance with the 8th article of the Artistic License:
        "Aggregation of this Package with a commercial distribution is
        always permitted provided that the use of this Package is embedded;
        that is, when no overt attempt is made to make this Package's
        interfaces visible to the end user of the commercial distribution.
        Such use shall not be construed as a distribution of this Package."
Therefore, you are absolutely free to place any license on the resulting
executable, as long as the packed 3rd-party libraries are also available
under the Artistic License.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.  There is NO warranty; not even for
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@centos63 tmp]# cpanm --help
Usage: cpanm [options] Module [...]
Options:
  -v,--verbose              Turns on chatty output
  -q,--quiet                Turns off the most output
  --interactive             Turns on interactive configure (required for Task:: modules)
  -f,--force                force install
  -n,--notest               Do not run unit tests
  --test-only               Run tests only, do not install
  -S,--sudo                 sudo to run install commands
  --installdeps             Only install dependencies
  --showdeps                Only display direct dependencies
  --reinstall               Reinstall the distribution even if you already have the latest version installed
  --mirror                  Specify the base URL for the mirror (e.g. http://cpan.cpantesters.org/)
  --mirror-only             Use the mirror's index file instead of the CPAN Meta DB
  --prompt                  Prompt when configure/build/test fails
  -l,--local-lib            Specify the install base to install modules
  -L,--local-lib-contained  Specify the install base to install all non-core modules
  --auto-cleanup            Number of days that cpanm's work directories expire in. Defaults to 7
Commands:
  --self-upgrade            upgrades itself
  --info                    Displays distribution info on CPAN
  --look                    Opens the distribution with your SHELL
  -V,--version              Displays software version
Examples:
  cpanm Test::More                                          # install Test::More
  cpanm MIYAGAWA/Plack-0.99_05.tar.gz                       # full distribution path
  cpanm http://example.org/LDS/CGI.pm-3.20.tar.gz           # install from URL
  cpanm ~/dists/MyCompany-Enterprise-1.00.tar.gz            # install from a local file
  cpanm --interactive Task::Kensho                          # Configure interactively
  cpanm .                                                   # install from local directory
  cpanm --installdeps .                                     # install all the deps for the current directory
  cpanm -L extlib Plack                                     # install Plack and all non-core deps into extlib
  cpanm --mirror http://cpan.cpantesters.org/ DBI           # use the fast-syncing mirror
You can also specify the default options in PERL_CPANM_OPT environment variable in the shell rc:
  export PERL_CPANM_OPT="--prompt --reinstall -l ~/perl --mirror http://cpan.cpantesters.org"
Type `man cpanm` or `perldoc cpanm` for the more detailed explanation of the options.

個人必裝的是

cpanm Net::Telnet::Cisco
cpanm Mail::Sendmail
cpanm Mail::Sender
cpanm MIME::Lite
cpanm Mail::Builder::Simple
cpanm pp

沒有留言:

張貼留言