How to run Perl Program?


The following are the different ways to start Perl.

Interactive Interpreter

You can enter Perl and start coding right away in the interactive interpreter by starting it from the command line. You can do this from Unix, DOS, or any other system, which provides you a command-line interpreter or shell window.

$perl -e <perl code>               # Unix/Linux
or
C:>perl -e <perl code>             # Windows/DOS

Here is the list of all the available command-line options −

Sr.No.Option & Description
1-d[:debugger]
Runs program under a debugger
2-Idirectory
Specifies @INC/#include directory
3-T
Enables tainting checks
4-t
Enables tainting warnings
5-U
Allows unsafe operations
6-w
Enables many useful warnings
7-W
Enables all warnings
8-X
Disables all warnings
9-e program
Runs Perl script sent in  a program
10file
Runs Perl script from a given file

Script from the Command-line

A Perl script is a text file, which keeps Perl code in it and it can be executed at the command line by invoking the interpreter on your application, as in the following −

$perl script.pl             # Unix/Linux
or
C:>perl script.pl           # Windows/DOS

Integrated Development Environment

You can run Perl from a graphical user interface (GUI) environment as well. All you need is a GUI application on your system that supports Perl. You can download Padre, The Perl IDE. You can also use Eclipse Plugin EPIC - Perl Editor and IDE for Eclipse if you are familiar with Eclipse.

Before proceeding to the next chapter, make sure your environment is properly set up and working perfectly fine. If you are not able to set up the environment properly then you can take help from your system administrator.

All the examples given in subsequent chapters have been executed with v5.16.2 version available on the CentOS flavor of Linux.

Updated on: 28-Nov-2019

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements