Writing a Hello World! program in Perl is straightforward. Open a text editor and enter the following lines:
#!/usr/bin/perl
print "Hello World!";
Save the file as hello.pl.
In Windows I can leave that first line (#!/usr/bin/perl) out and the program runs. In a Unix or Linux environment you will need to leave that line in the program. To execute this program in Windows you will need to get a command prompt window open and you can do that by clicking Start > Run and entering cmd. In Vista just type cmd in the Start Search box. After entering cmd, press enter and you should be presented with a command prompt window like the one shown below.
If you have just installed Perl then you need to make sure that your PC knows where Perl is located. Check that by using the path command at the command prompt. The very long string that is returned from this command should contain an entry similar to C:\Perl\perl\bin. If it does not then review this article on ComputerHope.com to see how to add Perl to your path.
So now let’s run that Perl program. Simply navigate to the directory where your hello.pl program is saved and type perl hello.pl to run the program.