Table of Contents


There's something else new in the code above. The \ . You can see what this does -- it 'escapes' the special meaning of $ .

Escaping means that just the $ symbol is printed instead of it referring to a variable.

Actually \ has a deeper meaning -- it escapes all of Perl's special characters, not just $ . Also, it turns some non-special characters into something special. Like what ? Like n . Add the magic \ and the humble 'n' becomes the mighty NewLine ! The \ character can also escape itself. So if you want to print a single \ try:

print "the MS-DOS path is c:\\scripts\\";

Oh, '\' is also used for other things like references. But that's not even covered here.

There is a technical term for these 'special characters' such as @ $ %. They are called metacharacters. Perl uses plenty of metacharacters. In fact, you'll wear your keyboard pretty evenly during a night's perl hacking. I think it is safe to say that Perl uses every possible keystroke and shifted keystroke on a standard US PC keyboard.

You'll be working with all sorts of obscure characters in your Perl hacking career, and I also mean those on your keyboard. This has earned perl a reputation for being difficult to understand. That's entirely true. Perl does have such a reputation, no doubt about it.

Is the reputation justified? In my opinion, Perl does have a short but steep learning curve to begin with simply because it is so different. However, once you learn the character meanings reading perl code becomes much easier precisely because of all these strange characters.