Perl quick start


I use ActivePerl on Windows.  After installing Perl, open up a cmd prompt.  Execute cpan.bat from  c:\Perl\bin or the bin directory of where ever you installed Perl.  This will install the c compiler for you.

To install modules from CPAN, run cpan from  command prompt.  Type in install module name from cpan’s shell prompt.  the module name is case sensitive. (example:  cpan>install String::Util)

If Komodo edit have problem finding the installed perl intepreter,  add the path to perl at the front of edit->preference->environment->classpath.

If using ActivePerl, you can use ppm to see all installed modules.  It comes with a good set.  Just type ppm at the command prompt.

To expand @INC to include extra directories containing packages you have downloaded from CPAN:  Set user variable PERL5LIB to the path containing the packages (control panel->set environment variables).

Most of this stuff is in the Impatient Perl guide

String Concatenation:

$name = checkbook'; 
$filename = '/tmp/' . $name . '.tmp';

if, elsif, else, unless

File Operations:

open(my $filehandle, 'filename.txt')
or die "Could not open file";


close($filehandle) or die "Could not close";

Conditional Operator


Problem printing newline in Windows or to notepad compatible files

append print statement with chr(012).chr(015). This prints ASCII for CRLF.  If you are using different char set, use the equivalent octal value from the char set.  Note, this does not work in PHP.  Use PHP_EOL if “\n” doesn’t work in print.


Variable Declaration

The variables $a and $b are special variables used in the sort function of Perl and, for historical reasons, are exempt from the requirement to declare them.


Good link to Perl Regex

Bar Code generations:

Use CODE128 specification and PerlMagick.  GD::Barcode is also a good staring point.


Good link from Microsoft:

Good example link:

Good example of basics:


Good time module to use on Windows.  Default time module seems to have the year stuck at 1969 for some reason.

Multi-line Comments

=for comment
bunch of code to be commented out


Good Perl Array Link


Comparing arrays


Break out of a loop: