In the last article, you learned how to install Perl. It wouldn't make a lot of sense to install it on your computer if you never did anything with it, now would it? In this article, you'll take your first steps to becoming part of a wild and crazy breed -- a Perl programmer.
There are many ways to store data in a variable. For now we will focus on the below example:
$my_name = 'Hamburglar; ' # places the name Hamburglar in the variable
$my_iq = 1000; # places the value 1,000 in the variable
You'll note the # symbol followed by text above. This is known as a comment. Comments are lines of text that the computer cannot see. They are used to let other programmers (and even yourself) know what you intended a line of code to do. When the computer sees the # symbol, it skips the remainder of that line and moves on to the next.
Try the following code:
$my_name = 'James';
print "My name is below:n";
The above code will print out the following to your screen:
My name is below:
You will notice a few new additions to our code. The first is the line:
This must appear on the first line of every program you create. It tells the computer which directory to look in.
In addition, we added the print command, which tells the program to print something to the screen. And lastly, we added the n or new line code. This simply informs the program to go to the next line and not print the next line of text on the same line.