Perl

This is a newer API library into the CPAN repositories. It has a bunch of added functionality that CPAN doesn’t have. To install it, you can use CPAN:

Once done, exit

Has added functionality: Some of the nicer features are ability to search by modules (m Test::TCP) or authors (a DMAKI) from within the API. The output displays numbers next to the outputted modules so you can quickly install “i 1” (install #1 in the list). Ability to automatically install all dependencies a particular module install needs. Print error stacks (p), able to self-update itself. I’m sure there are many other cool features that I’m not covering but these are the main ones I tend to use.

So this sometimes drives me crazy, having to sit there and watch your CPAN perl module installation as it will stop the process only to ask you ..do you wish to also install whatever other needed dependency module. [yes] enter [yes] enter [yes] enter..

cpan> o conf build_requires_install_policy yes
cpan> o conf commit

Or using by using CPANPLUS, you can choose yes to all for each individual module.

Perl tips

Documentation
A unique feature of Perl is that it doensn’t come with just one man page, but with a whole slew of man pages that describe various aspects of Perl, and serve as tutorials, reference manuals, and FAQ pages. Here are some of the most useful of these pages for beginners:

Line-based operation
The simplest way to use perl in commandline mode is as a filter that operates on a file (or on standard input), manipulates the file one line at a time, and outputs the result to standard output, much like standard Unix utilities like grep, sed, and awk work.

The basic structure of the command is one of the following:

 

The commandline options used here have the following meaning:

The “e” option indicates that the following string is to be interpreted as a perl script (i.e., sequence of commands). To prevent interfering with the shell, it is best to enclose the script in single right quotes (‘).
The “l” (character “ell”, not the bar symbol) option ensures proper end-of-line handling; without it, linebreaks may get chopped off.
The “a” option causes perl to autosplit each line into an array of fields $F[0], $F[1], …, with blank space acting as default field separator. Note that in Perl, array indices start at 0, so the first array element has index 0.
The “p” and “n” options indicate whether or not each line is printed by default.

The following examples illustrate the use of Perl for line-by-line processing of files.

Operating on entire files
Perl’s power really shines when one wants to perform operations on chunks of files that extend over multiple lines (e.g., deleting line breaks in paragraphs). Standard Unix utilities like sed or awk are ill-suited for that, but with Perl this is easy by changing the record separator (which defaults to a linebreak) to something else using the ‘-0’ option. Of particular interest are the following cases:

Here are some examples using these modes:

Cool stuff