QUICK AND DIRTY PERL SETUP
Don't be alarmed. Perl is soft and cushy. It's the easy way to get things done. Perl handles the install and resolves all Perl dependencies for you. It will even make sure the packages haven't been tampered with at the archive by checking the MD5 hash for you if MD5 is installed.
Installing Perl
Here's what you need to get up and running and writing your code in under 1 hour (20 minutes if you're good).
- Log into the Unix/Linux box of your choice where you will be running perl
scripts.
- The easy way is to browse to the CPAN ports archive for perl and download it from there. Simply click the link for your operating system and version and follow the links. Perl is included as part of a standard operating system installation for the following operating systems:
- BSD (all distributions)
- Sun Solaris 8 (Solaris 5.8) and later
- HP-UX 11.00 and later
- Mac OS X (nice to see Apple going with non-proprietary software for once).
- IRIX 6.4 and later
If you insist on running Microsoft Windows or cling to Mac OS 9 or earlier, you're out of luck. You'll have to download and install a copy of Perl. I have used the Active State perl distribution for Windows for years and it works quite well; they also make a version for Mac OS X.
- Once you've installed the true Perl binary, you need to run the CPAN module as root or an account with root level permissions with the following commands:
% cd /
% sudo -s
Password: ********
# perl -MCPAN -e shell
Capitalization is important.
CPAN is a module that is designed to make it easy to download and install perl modules from the CPAN archive. CPAN will walk you through setting itself up if you haven't done it already. Most of the questions you will be asked have to do with where certain binaries are found on the system, such as make. Accepting the defaults as offered by the script has worked for me every time so far.
- If you're using the Active State distribution, use the ppm module included with the package to update the Active State perl distribution. You can run CPAN from the Active State distribution, but you don't have make or gzip which perl requires to unpack and build the downloaded modules.
Update Critical Perl Modules
- The first thing you want to update is the CPAN module itself. The CPAN module is included with Perl and can be updated or downloaded from CPAN www.cpan.org. To get CPAN updated
run the following command from within the CPAN prompt that we started with the previous perl command.
cpan> install Bundle::CPAN
- Follow the prompts. It may already be up to date, if so, jump to the next
step. Updating CPAN has little impact on Perl's behavior. This should be
transparent to your current perl scripts.
- Next, we reload the CPAN libraries to refresh them while we're still running CPAN:
cpan> reload cpan
This updates the current perl libraries for CPAN without having to exit CPAN.
- install the MD5 library
cpan> install Bundle::MD5
- Install IO::Stty. This is not a manadatory prerequisite but some scripts and tools work better with this module installed. It also makes the Expect module run a bit more cleanly.
cpan> install IO::Stty
And that should do it.
Also... CPAN has built in help. Just type '?' or 'help' at the CPAN prompt and press enter.
Searching the CPAN archives
To search the CPAN archive, you can launch CPAN:
# perl -MCPAN -e shell
..and then search for modules in the CPAN archive using the command:
cpan> i /<module name>/
Built in Online Help
Most everything in perl comes with built-in documentation. That documentation is in 'plain old documentation' format or pod format. The command perlpod is installed with perl and allows you to extract and read this documentation. The documentation for most modules is stored inside the perl module itself as inline comments on the code.
If you want documentation about an installed module, you can use the 'perldoc' command which basically greps/formats comments included in the modules and pakges. Documentation for most things in perl is usually excellent and almost always provide sample code to explain how to call methods and functions.
For example:
[user@localhost]/export/home/user> perldoc Net::SCP::Expect
Offline Documentation
A. Perl has a built in debugger covered quite fully in the O'Reilly books
and you can execute perl snippets directly from the command line using
perl -e { ..statements.. }.
BOOKS
O'Reilly - Programming Perl 3rd edition; Larry Wall, Tom Christiansen &
Randal L. Schwartz
O'Reilly - Perl Cookbook; Larry Wall, Nathan Torkington
http://www.cpan.org
http://www.cpan.org/modules/by-module/Net/Net-SCP-Expect-0.10.readme
http://www.perl.com
http://www.perl.org
[an error occurred while processing this directive]