Introduction of Perl

Perl stands for “Practical Extraction and Report Language� and it named so because of its typical use in extracting information from a text file and printing out report for converting a text file into another form.

But now it is widely used for a wide range of tasks including system administration, web development (Perl CGI is used) , network programming, GUI development and many more.

Note: “Perl� with a capital P refers to the language and “perl� with a lowercase p refers to the actual interpreter that compiles and runs your program.

Perl history?

Have you ever thought of why the “Perl� is not written in all caps, its because the Perl’s creator Larry Wall came up with the name first and expansion later. So, it is actually backronym, not an acronym.

  • Its first version was released in 1987.
  • Perl 2, released in 1988 adding a much better regular expression engine.
  • Perl 3, released in 1989 adding support for binary data streams.
  • Perl 4, released in 1991 with a better documentation than earlier.
  • Perl 5, released on October 17, 1994. It added many new features to its last version like objects, variables, references and modules.

Perl features?

  • Easy to use, as it supports both procedural and object-oriented (OO) programming, has powerful built-in support for text processing, and has one of the world's most impressive collections of third-party modules. Its intended to be practical rather than beautiful.
  • Derives the power of other language and tools, low level programming such as C and the high level programming such as Shell programming, some of the power of more advanced tools like grep, cut, sort, sed and awk.
  • Perl supports sed-to-Perl translator and awk-to-Perl translator.
  • Interpreted Language, you can write your programs and test them without an intermediate compilation step, which allows you to experiment and test/debug quickly and easily.
  • Open source and free software.
  • Cross platform programming language, it can be executed on windows system, linux system, mac OS etc.
  • Dynamically typed language, no need to pre declare your variable, Perl automatically converts it to string, integer, floating point numbers depending upon its value. For example if the value is 5 then it is considered as integer, if its 5.0 then its floating point number etc.
  • Wide varieties of conditional and looping constructs, Perl is having if-elsif-if conditional statement, Unless conditional statement (Negated version of If), Given-when conditional statement (switch statement), While loop, Until loop (Negated Version of While), For loop and Foreach loop.

Interpretive vs Compiled programming language?

Perl is an interpretive language which means that the code is not required to be converted to byte code and then run the byte code. Perl interpreter can run the Perl direct source code.

Other languages like Java where the source code need to be converted to byte code and then that byte code file is executed. This is known as Compiled implementation.

Basic Program [Installation in next tutorial]

Perl program to print "Hello World"??

Line 1: #!/usr/bin/perl
Line 2: use strict;
Line 3: use warnings;
Line 4: print "Hello, world!\n";

Explanation of each line:
Line 1: This is known as shebangor she-bang or sh-bang# character is the Perl comment character. It tells the system that the line is not an executable instruction. ! character is a special character; it indicates what type of program this is.

The path /usr/bin/perl is the location of the Perl executable on your system. This executable interprets your program; in other words, it figures out what you want to do and then does it. Because the Perl executable has the job of interpreting Perl instructions, it usually is called the Perl interpreter.

Line 2: use strict; it's a safety net, Perl by default is very forgiving so to make it robust it is recommended to start every program with this line. It is pragma which disables certain Perl expressions that could behave unexpectedly or are difficult to debug, turning them into errors.

For example, if the variable is not declared with my keyword it will throw error.

Line 3: use warnings; It is pragma which gives control over warnings.

Line 4: print is the predefined function of the Perl programs which will take "Hello World"? as its parameter and write in the output console.

Note : Except the comment line all the other lines are ended up with the semi colon ; (Perl statement ends in a semi colon) Save the above program with .pl extension. For example :

How to execute it in Unix?

  • Check if the Perl is installed or not in your system.
    perl -v

  • Give the executable permission to the Perl program before executing it.
    chmod 755

  • You can also check the syntax error by passing -c parameter.
    perl -c

    Note: It will only check the syntax of the program.

  • Using the perl command the Perl programs can be executed.

The above program can be written in one line as well:

perl -e ‘print “Hello World \n�;’

-e is used to take the Perl statements through command line and execute it.

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Recent Addition

new tutorial Protractor Online Training : We have closed registration for training

Please do email to for any queries

If you already registered then please do check your email for the Webex link