![]() |
Perlaccess : Tutorials : Input and Output Hello World! (2.1) by Jacob A. Wheeler http://www.bigresources.com |
Now going through, line by line, i will break down what everything means. # Line 1 The very first line of EVERY perl program needs to declare the path to the perl interpreter. In otherwards, this path needs to point to whatever directory PERL is installed in on your system. known as pound(#)-bang(!) followed by the path to perl. Wondering where perl is installed on your server? If you have shell access (telnet, ssh) you can type the following command: whereis perl Otherwise,
you will most likely find perl installed to the following
dirs (on most systems): # Line 2 Line 2 simply contains a bunch of comment signs (aka remarks in other languages) Commenting your code can be a big help, especially when making future modifications on your scripts, or someone else needs to go through later on to perform updates to your scripts. It also helps people figure out what in the world you are doing. [ Back To Top ]# Line 3 This line of code tells the browser how you want to display your output of your script. In our case, we will only be outputing basic text and html. [ Back To Top ]# Line 4 This is one of the classic output examples. When the script is ran, the following will be displayed: Hello World! To output data to the screen, simply type print ""; And you place all text you would like outputed to the screen within the two quotes, followed by a semicolon. NOTE: perl is very sensitive, which means if you forget one quote, or one semicolon, your script will return a server error, and not run. FAQ: How do I output the following HTML tag which contains quotes? <font face="arial" size="2">Size 2 Text</font> Solution: In order for perl to properly format the outputed data you must include a \ before each quote you would like ignored. Eg: <font face=\"arial\" size=\"2\"> Size 2 Text</font> So
your code would look like: And when your html code is displayed by the script the backslashes won't even show up. [ Back To Top ]# Line 5 The text 'exit;' simply tells perl to literally exit the program, or kill the script. Forcing your script to stop. [ Back To Top ] |