Friday, February 28, 2014

Hello World!

Ok, now we are going to make the traditional 'Hello World!' script.

For those unfamiliar to this programming tradition, it is basically a script, that upon execution prints out the text "Hello World!" on your screen.

Now, here is the explanation for the above code:

Line 1:  
#!<some path> ----> this is required for your script to work, it tells where the perl files are located.  #!/usr/bin/perl is saying that perl files are located in a local folder, which is located at /user/bin/perl  

The above is correct for a Linux system, where Perl is installed in its default location. 

While -T is for taint mode (a security feature) and w is for warnings.

Line 2: use strict is a security feature, and is strongly recommended!

Line 4: This line is very very important, and you would need to use it in all pages generally. It says, that after this whatever is accompanied with a print command, is shown on the monitor.

Line 5: This is the first print command, that would be displayed on screen. Try typing anything instead of the 'Hello World!' text. The \n is for newline after the text.. similar to what we use in C++

The last thing to do now, is to copy the above code, into one of your favorite text editor like Notepad++ and save the file as

Then put it into the cgi-bin folder, on your website and set its permissions as 600 or 700 or 705. To test it, set its permission as 700, and then go to:

You should see a Hello World! written on the top-left side.

Note: You might need to add the following line for shared hosting accounts, like of Godaddy, since they have cpanel installed, make this your Line No.2 in that case:

use cPanelUserConfig; #needed for shared hosting having cpanel like Godaddy

No comments:

Post a Comment

Please do not paste any links, such comment would be deleted. Thanks!