The PRINT command in Perl is probably the most known and used. It is used to display things to the monitor screen.
I will start with the famous "Hello World!". Why is this the starting page for everyone to create? Oh well, who am I to mess with a good thing? LMAO! If you are unfamiliar with this concept... this is an extremely simple page/script that will print the words "Hello world!" on the screen.
Print is a built in Perl function. It sends output to a specific location. The location is "STandarD OUTput" also known as STDOUT. For the rest of us common folks, that means "the monitor screen". The print command is specific to the monitor screen, so stating an actual <STDOUT> command is unnecessary.
Ready for the code?
See it in action!
The first line (shebang) tells the coding where to find the Perl translator. You should have read about this back on the BASICS page. The second line tells the browser that this PERL is working on the Internet. The last line states to print the following message. By default, it assumes STDOUT so the message will appear on the monitor screen.
The PRINT command is actually a very powerful one. It can be used to display parts of a web page using HTML coding, or even an entire web page! That circumstance is probably a bit out of the ordinary, but the possibilities are there.
See it in action!
You will find the PRINT command rather handy as the tutorials go further.
I will start with the famous "Hello World!". Why is this the starting page for everyone to create? Oh well, who am I to mess with a good thing? LMAO! If you are unfamiliar with this concept... this is an extremely simple page/script that will print the words "Hello world!" on the screen.
Print is a built in Perl function. It sends output to a specific location. The location is "STandarD OUTput" also known as STDOUT. For the rest of us common folks, that means "the monitor screen". The print command is specific to the monitor screen, so stating an actual <STDOUT> command is unnecessary.
Ready for the code?
|
#!/usr/bin/perl print "Content-type: text/html\n\n"; print ("Hello World!"); |
The first line (shebang) tells the coding where to find the Perl translator. You should have read about this back on the BASICS page. The second line tells the browser that this PERL is working on the Internet. The last line states to print the following message. By default, it assumes STDOUT so the message will appear on the monitor screen.
The PRINT command is actually a very powerful one. It can be used to display parts of a web page using HTML coding, or even an entire web page! That circumstance is probably a bit out of the ordinary, but the possibilities are there.
|
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "<html><head><title>Test</title></head><body>\n"; print "<h1>Hello world!</h1>\n"; print "</body></html>"; |
You will find the PRINT command rather handy as the tutorials go further.

