Hello World - Your Very First App

1 post Page 1 of 1
Contributors
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Hello World - Your Very First App
Usman55
If you haven't already, then head over to viewtopic.php?f=231&t=11530 in order to get a brief introduction of PERL and to know how to download and install it before moving further into this tutorial.

After successfully installing PERL and an editor, open up Padre. It's time to make our first app.
Go to File -> New -> PERL 5 Script.
That would create a new script page where we're going to write our code.

For our first app, we're going to print "Hello World!" in command line. To do so, type the following code in the script:
Code: Select all
#!/usr/bin/perl
print "Hello World!\n";
The first line tells the computer what to do with the script i.e. to run it through PERL, which is located in the specified directory. It could be different for different users depending on the installation directory.

In the second line, print means to display text on the screen i.e. on the command prompt. "" defines which text is to be displayed. Double quotations are preferred over single ones as they provide compatibility with symbols and new lines.

When you run the program, the editor will ask you to save it somewhere first. A folder in Documents is a good choice. After you save it, a command line will be displayed and a message "Hello World!" will be printed it it. Congratz! You've just made your first PERL app.

PERL is similar in code to many other languages like C. Comments can be added to the code by adding a hash before them like:
Code: Select all
#This is a comment
Every code needs to have a semi-colon at it's end. This defines simple statements. The following code is also a statement.
Code: Select all
print "$key is from $residence{$key}\n";
Now that you've been able to make your very first app, the purpose of this tutorial is complete. Move on to the next tutorial to learn about variables in Perl:
viewtopic.php?f=231&t=11532
Image
1 post Page 1 of 1
Return to “Tutorials”