Perl is a versatile and dynamic programming language commonly used for text processing and system administration tasks. Known for its rich text manipulation capabilities and powerful regular expressions, Perl excels at tasks involving parsing and manipulating large amounts of data. While Perl has traditionally been popular in the domain of system administration and scripting, it is still actively used in web development and other areas where its strengths in text processing and flexibility are valued.

Module 1: Introduction to Perl

Introduction to Perl

Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl emphasizes support for common computing tasks such as file scanning, text manipulation, and task automation.

print "Hello, World!\n";

Variables and Basic Data Types

In Perl, you have Scalars, Arrays, and Hashes. Scalars can hold both number and string data. Arrays are ordered lists of scalars indexed by number, and Hashes are unordered sets of key-value pairs.

$name = 'John Doe';
@ages = (25, 30, 40);
%data = ('John Paul', 45, 'Lisa', 30);

Control Flow

Perl offers several control flow constructs like if, else, unless, for, foreach, and while.

$a = 10;
if( $a < 20 ) {
	print "a is less than 20\n";
} else {
	print "a is not less than 20\n";

Module 2: Subroutines and Regular Expressions in Perl


Subroutines or functions are the basic building blocks of reusable code. The keyword sub precedes the function definition.

sub Hello {
	print "Hello, World!\n";


Regular Expressions

Regular expressions are strings with the very particular syntax and meaning described in perlreref and perlre.

$string = 'Hello World';
$string =~ s/World/Perl/;
print "$string\n"; # Prints 'Hello Perl'

Module 3: File Handling and Modules in Perl

File Handling

Perl provides a broad range of file and data I/O functionality for a wide range of real-world applications.

open(DATA, '<file.txt');
while(<DATA>) {
	print "$_";


A Perl module is a reusable collection of related variables and subroutines that perform a set of programming tasks.

use Math::Trig;
print pi;