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
C:>perl -e <perl code>             # Windows/DOS

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

Sr.No.Option & Description
Runs program under a debugger
Specifies @INC/#include directory
Enables tainting checks
Enables tainting warnings
Allows unsafe operations
Enables many useful warnings
Enables all warnings
Disables all warnings
9-e program
Runs Perl script sent in  a program
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             # Unix/Linux
C:>perl           # 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.