Table of Contents

Using Perl

perldoc

The perl documentation system:

  • perldoc perl (info about perl), perldoc perldata ((perl datastructures), perldoc perlfaq1 (1-3+ faqs)
  • perldoc -q “send mail” (search the FAQs for ‘send mail’)
  • perldoc -f sort (lookup sort function in perl)
  • perldoc CGI (some modules have built in documentation)
  • perldoc MP3::Info (read documentatio on the MP3::Info module)

installing modules

Need to run commands as owner of perl files, usually root

  • perl -MCPAN -e shell ‘install “MP3::Info”’
  1. perl -MCPAN -e shell (or a small script called cpan)
  2. [force] install MP3::Info (sample way to install a module)
  3. quit

A few other useful commands in the CPAN shell are

  i /mp3/        - search for all modules with /mp3/ in the name
  i MP3::Info    - show information about this module
  look MP3::Info - download a module and start a subshell where you
                   can look around before installing
  readme MP3::Info - show the readme file for the module
  ?              - show command summary

private modules

There are several ways to use modules installed in private directories:

  • setenv PERL5LIB /path/to/module
    • sets the environment variable PERL5LIB.
  • use lib qw(/path/to/module);
    • used at the top of your script tells perl where to find your module.
  • perl -I/path/to/module

All of these will append /path/to/module to @INC.

 
perl/using_perl.txt · Last modified: 2005/09/22 22:02 by bw
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki