This is the first perl script to write.
--------------------------------------------------------------------------------------
#!C:/Perl/Bin/Perl
#prints the words “hello world” with a leading next-line character
print “Hello World\n”;
-------------------------------------------------------------------------------------
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.
Line 2
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.
Line 3
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.
That’s it!
No comments:
Post a Comment