Introduction to PERL and its features

 

Introduction to PERL & Its Features 

  • Perl stands for “Practical Extraction and Report Language”. 
  • Perl is a general-purpose programming language, and can be used for practically any programming task any other high-level language can be used for.
  • However Perl is usually thought of as a glue language, so called beause it binds things together (such as works with HTML, XML, and other mark-up languages, connects the database to the web).
  • Perl takes the best features from other languages.
  • Perl is very flexible and is currently available on over two dozen operating system platforms.
  • Perl supports both procedural and object-oriented programming.

 

Installing PERL

PERL Version:

    •  The current versions of Perl are all in the 5.X and 6.X series (6.X was released in 2001). If you have an older version of Perl you can upgrade it as many changes were made between releases.

PERL installation:

  • Many operating systems (Linux and UNIX) come with Perl installed. You can easily check whether Perl is loaded on your system by opening a terminal window and issuing the command:
    perl –v
    If you get a version number, Perl is installed. If you get an error message about command not found (or something similar), Perl is not installed.
  • For windows operating system you can install the strawberry PERL software. 
  • Every release version of PERL comes with documentation in a set of files.
  • Most of release versions have over 2,000 pages of documentation included in reference books, user guides, FAQs, and so on.
  • On most of operating systems, a utility called perldoc is installed as part of the Perl system.
  • The perldoc utility can search for and format Perl documentation for you.
  • To use perldoc to look up the basic syntax for perl, open a terminal or console and issue the command:
    perldoc perl
  • To search for a particular keyword, use the –tf options. For example to look up the print keyword: perldoc –tf print

First PERL Program

The Basic Hello World Program:

Program:

Step1: Open any editor in your terminal

Step2: Write your Script

    #! /usr/local/bin/perl -w

    print “Hello World!\n”;

Step3:  Save this as hello.pl.

     #File extension is not compulsory to define

Step 4: Give it executable permissions
     chmod u+x hello.pl or chmod a+x hello.pl

Step5: Run ./hello.pl

Constraints & Explanation:

  • The first line “#!/usr/local/bin/perl”  tells UNIX where to find Perl. (We can search :By writing command “which perl” in linux terminal. )
  • “-w” switches on warning: not mandatory but really good idea to have it.
  • All comments in Perl are written starting with a # sign.
  • All valid Perl command lines end in semicolons. Without a semicolon, Perl continues to read onto the next line and doesn’t assume a carriage-return in the end of a statement.
  •  We can ignore semicolon in last line of PERL Program.
  • Whitespace is ignored by the PERL interpreter.
  • You can use whitespace (spaces and tabs) anywhere in your programs
  • The print function tells Perl to display whatever follows, such as a  string, variable name
  • For example, the command:
    print “Hello World\n”;    Will print “Hello World” followed by a newline.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *