Perl programming language is exclusively designed for text processing purposes. Its abbreviation denotes Practical Extraction and Report Language. It is compatible on various platforms, such as Windows, Mac OS, and almost all versions of UNIX.
Hello World! program in every programming language gives the beginner programmer a leap in proceeding further in the new language. The basic Hello world program just gives the output by printing ” Hello World!” on the screen. In Perl, a basic program consists of the following steps of execution,
Step 1: Transfer the file to Perl Interpreter:
Always in Perl, the first line starts with a pair of characters #!. It insists Perl interpreter how the file should be executed. Here, the file should be transferred to Perl interpreter that resides in /usr/bin/perl folder. So, the first line of the program will go this way,
#!/usr/bin/perl
Step 2: Pragma in Perl:
A pragma is a specific module in Perl package which has the control over some functions of the compile time or Run time behavior of Perl, which is strict or warnings. So the next two lines go like this,
use strict;
use warnings;
Step 3: Use of print() function:
Lastly displaying the output, We use print() function to display a string in perl.
print("Hello World\n");
Code:
use strict;
use warnings;
print ( "Hello World\n" );
|
Output:
Hello World
Important Points:
- The file must be stored with an extension of .pl
- Directory of the Perl Package must be same as to where the Program file is saved.
How to Run a Perl Program?Generally, there are two ways to Run a Perl program-