Wednesday 18th September 2019,

Brief Introduction to Perl

admin March 16, 2014 Latest News No Comments

In this blog, one of the most used web languages Perl will be discussed in detail including the features, code samples and the well known companies who are using it.


Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular amongst programmers. Larry Wall continues to oversee development of the core language, and its upcoming version, Perl 6.

The Features of Perl

The overall structure of Perl derives broadly from C. Perl is procedural in nature, with variables, expressions, assignment statements, brace-delimited blocks, control structures, and subroutines.

Perl also takes features from shell programming. All variables are marked with leading sigils, which unambiguously identify the data type (for example, scalar, array, hash) of the variable in context. Importantly, sigils allow variables to be interpolated directly into strings. Perl has many built-in functions that provide tools often used in shell programming (although many of these tools are implemented by programs external to the shell) such as sorting, and calling on operating system facilities.

Perl takes lists from Lisp, hashes (“associative arrays”) from AWK, and regular expressions from sed. These simplify and facilitate many parsing, text-handling, and data-management tasks. Also shared with Lisp are the implicit return of the last value in a block, and the fact that all statements have a value, and thus are also expressions and can be used in larger expressions themselves.

All versions of Perl do automatic data-typing and automatic memory management. The interpreter knows the type and storage requirements of every data object in the program; it allocates and frees storage for them as necessary using reference counting (so it cannot deallocate circular data structures without manual intervention). Legal type conversions — for example, conversions from number to string — are done automatically at run time; illegal type conversions are fatal errors.

Example code

In older versions of Perl, one would write the Hello World program as:

    print "Hello World!\n";

In later versions, which support the say statement, one can also write it as:

    use 5.010;
    say "Hello World!";

Good Perl practices require more complex programs to add the use strict; and use warnings; pragmas, leading into something like:

    use strict;
    use warnings;

    print "Hello World!\n";

Here is a more complex Perl program, that counts down the seconds up to a given threshold:

 use strict;
 use warnings;
 use IO::Handle;

 my ( $remaining, $total );

 $remaining = $total = shift(@ARGV);


 while ( $remaining ) {
  printf ( "Remaining %s/%s \r", $remaining--, $total );
  sleep 1;

 print "\n";

The perl interpreter can also be used for one-off scripts on the command line. The following example as invoked from an sh-compatible shell such as Bash translates the string “Bob” in all files ending with .txt in the current directory to “Robert”:

     $ perl -i.bak -lp -e 's/Bob/Robert/g' *.txt

Well known companies who are using Perl

International Companies: Nokia and Opera Software.

U.S. Companies: Apple, Amazon, Google and Yahoo.

Like this Article? Share it!

About The Author

Comments are closed.