Perl - Practical Extraction and Report Language

Published: Friday, 30 April 2004

Perl is a scripting language that can accomplish all kinds of neat things. The official website is

Before you go ahead and write a new program in Perl, check out the Comprehensive Perl Archive Network. Hundreds of modules are freely available for Perl to integrate with different APIs, and very rarely would you need to develop a new one. The CPAN Frequently Asked Questions contains quick answers to many general questions about modules.


Methods or functions in perl can be done using the sub keyword

sub print_hello {
  print "hello\n";

After defining the subroutine you can call it using print_hello()

To pass a parameter you can use shift


sub dump_stats {
	my $hour=shift;

Then the local var $hour, will have the value of 11.

String matching

Use =~ to test if a pattern matches a string variable.

     if ($foo =~ /bar/) {
       print "The variable foo matches bar";