jump to navigation

#1 – Hello World July 24, 2006

Posted by takeuaway in Basic Perl, chapter 1.
trackback

This is the first perl script to write.

—————————————–

#!C:/Perl/Bin/Perl

print “Hello World\n”;

#prints the words “hello world” with a leading next-line character

—————————————–

The first line must always start with the “shebang” character -”#!”, followed by the location of where your perl interpreter resides.

I am using windows, but i suggest to use the “/” instead of the “\” as the folder separator because next time if you write a perl script on the apache server, all the “\” folder separator must be changed to “/” for it to work propely.

The second line uses the print command to print the trailing text unto the standard output.

Note that except for the first line, all lines should end with a “;” to indicate the end of the line.

The 3rd line is a comment, it will not be executed. A comment is indicated by a “#” at the beginning.

Save the file as hello.pl and run perl hello.pl in the command prompt.

hello world

That’s it!

Comments»

No comments yet — be the first.