Summary: in this tutorial, you will learn how to develop the simple but famous Perl Hello World program.
We assume that you already have Perl IDE installed in your system. If so, you’re ready to go. If not, you can go back to the setting up Perl development environment tutorial to install DWIM Perl for Windows. It is very easy to setup.
First, launch Perl IDE and type the following code:
Second, save the code into a file in a folder e.g., C:\PerlWS and name the file as
hello.pl. You can do this by either press keyboard shortcut Ctrl + S or click on the menu item File > Save. Notice that Perl source code file has *.pl extension.
Third, press F5 keyboard or select the menu item Run > Run Script. A command line window will display and you will see the Hello World message as the following picture:
Congratulation, you’ve successfully developed the first working program in Perl in three easy steps.
Let’s examine the program line by line, one at a time, to understand what it does.
The first line of the program is:
The first line begins with a pair of characters #!. It tells Perl how the file should be executed. In this case, the file should be transferred to Perl interpreter that resides in
The second line of the program is:
It is called pagma in Perl. It instructs Perl to turn on additional warning reporting. In the next tutorial, you will see another pagma such as
use stricts which is highly recommended to use.
The third line of the program is:
print() function to display a string. A string in Perl must be inside quotes. You will learn more about Perl string in the next tutorial. The
\n at the end of the string is an escape sequence which is known as a new line. It instructs Perl to start a new line.
You’ve taken the first step in Perl programming by developing the first simple Perl Hello World program. Hopefully, you have had it executing successfully. If you haven’t, please get through it. As always, learning by practicing is the best way to learn, especially in programming.