blank'/> muhilneel: Developing and Executing Perl

Thursday, November 29, 2012

Developing and Executing Perl

         Perl is an interpreted language.So, no compilation is needed.
                   An interpreted language is a programming language that is compiled into machine readable code at the moment it is run by the languages interpreter. Examples of interpreted languages are Perl, PHP, Ruby, and Python.This is in contrast to a compiled languages like C, C++, or Java. These languages are pre-compiled or compiled into machine readable code once by a language compiler. This creates an executable in the machine's native language that can then be run many times.
                     To use Perl, one should create a text file containing the Perl program.This file can be created using any text editor available in the system.In order to  designate them as perl scripts, the file names should have an extension ".pl"

             For example,the perl file can be saved as firstprogram.pl

         This file can be executed on the command prompt as

                               c:/>  perl  firstprogram.pl
This command will display the error messages in the code if any or the code will be executed.

                     The basic output in Perl is obtained using the Print command.The print command echos the string and expressions on the screen.

                                  Print      " My first Perl program \n";

  • The  string constants are represented using double quotes (" ").
  • The  newline character prints the output in a new line (\n).
  • The semi-colon indicates the   end of Perl command.Each and every Perl statement  should be terminated with a semi-colon.

The output of the above given perl code will be

                         My first Perl program

Since we have specified to be printed on a new line (\n), the output will be printed on a new line.

No comments:

Post a Comment