What is Perl ?

Perl is a high level and general purpose programming language. It is used to create web applications. It is Practical Extraction and Report Language. It is open source language software. It was created by Larry Wall.

Features of Perl:

Perl language has the basic features of many languages e.g. C, BASIC, awk etc.
Perl supports database i.e. Oracle, MySQL, Sybase and others.
Perl works with mark up languages too.
Perl supports Unicode.
It supports object oriented programming and is procedural too.
Perl embedded with Web:

Perl is popularly known for creating web applications.
It is called as duct-tape of the internet.
It can handle the encrypted web data.
Perl as Interpreted language:

Perl is said to be an interpreted language and it can be executed without compiling. When Perl program is run, it is converted into byte code first and then changed to machine instructions.

Programming in Perl:

Programming in Perl can be Interactive mode or script mode programming. Interactive Mode Programming: This is done using –e option at command line that helps to execute the statement from command line.

For e.g. - $perl –e ‘print “Hello World ”’ The output would be Hello World Script mode programming: Using the script mode, we can open a file and can add lines to the file that can be executed. File extension in Perl:

A Perl file is saved with .pl or .PL extension. Names of file can have symbols, numbers, and alphabets but no space. An underscore can be used in place of spaces.

Comments in Perl:

Comments are generally used so that program can be user friendly and can be understood by any user who is reading the code written by someone else for the first time. # can be used in the starting of the line to write the comment. A number of lines can be commented in a while using = sign in the beginning of first line and last line.
Whitespaces in Perl:

Whitespaces are ignored in Perl.
Print “Hello World”; Print “Hello World”;
Above two statements are same in Perl and would give the same output.
Single quotes and Double quotes:

The main difference between single quotes and double quotes in Perl is that double quotes interpret the variables and special characters e.g. new line character . For e.g. print “Hello World ” will produce output as Hello World Print “’Hello World ’ will produce the output as Hello World In Perl, is used to escape any type of character. Data type is generally not defined in Perl as it is a typed loosely.

The data types in Perl:
1) Scalars – These are simple variables and contains $ sign in the starting.
2) Arrays of scalars – These are list of scalar variables. These are referenced by using index which is starting with 0. These contains @ sign in the starting.
3) Hashes of scalars / associative arrays – These are also the list of variables but these are unordered. They contain % sign in the starting.