Robert's Perl Tutorial

http://www.sthomas.net/roberts-perl-tutorial.htm


$ % @ are Good Things

If you have any experience with other programming languages you might be surprised by the code $var=10. With most languages, if you want to assign the value 10 to a variable called var you'd write var=10.

Not so in Perl. This is a Feature. All variables are prefixed with a symbol such as $ @ % . This has certain advantages, like making programs easier to read. Honestly, I'm serious! It just takes some getting used to. The prefixes mean that you can see where the variables are quite easily. And not only that, what sort of variable it is. The human language German has a similar principle (except nouns are capitalised, not prefixed with $ and Perl is easier to pronounce). You'll agree later, I think.

So, ever onwards. Time to try some more variables:

$string="perl";
$num1=20;
$num2=10.75;
print "The string is $string, number 1 is $num1 and number 2 is $num2\n";