Thursday, December 2, 2010

How to use Perl for writing a program and executing it?

Following are the numbered steps, that are needed to be followed for successful 
execution of a Perl script :

1) Install Perl in your UNIX/ LINUX system ( get it from http://www.perl.org/get.html ),
if not already installed.

2) Open any text editor in your system and write the codes for the script.

3) Save the script by specifying a file name  with a ".pl" or ".cgi" extension 
( optional ). e.g: test.pl

4) In the above step the script file created can be stored in any location of your 
system but try to save the file in the "cgi-bin" folder ( which is automatically 
created at the time of Perl installation ) because then the script can also be run 
as a CGI script if requirement arises.

5) Finally the script can be executed as follows:
  • Go to the command prompt of your system and change directory to the location where the script is stored.
  • Type "perl file name.pl" and then hit enter. e.g: perl test.pl
  • or if running a CGI script, then open any web browser and type "http://server_address/cgi-bin/" and then hit enter. e.g: http://localhost/cgi-bin/test.pl