Robert's Perl Tutorial

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


Context: About Perl and @^$%&~`/?

Perl uses so many weird characters that there aren't enough to go round. So sometimes the same character has two or more meanings, depending on its context. As an example, the humble dot . can join two variables together, act as a wildcard or become a range operator if there are two of them together. The caret ^ has different effects in [^abc] as opposed to [a^bc] .

If this sounds crazy, think about the English language. What do the following mean to you ?

Mean is, in one context, is a word to used describe the purpose of something. It is also another word for average. Furthermore, it describes a nasty person, or a person who doesn't like spending money, and is used in slang to refer to something impressive and good.

That's five different uses for 'mean', and you don't have any trouble understanding which one I mean due to context.

Polish, when capitalised, can either mean pertaining to the country Poland, or the act of making something shiny. And 'like' can mean similar to, or affection for.

So, when you speak or write English (think of two, to and too) you know what these words mean by their context. It is exactly the same way with Perl. Just don't assume a given metacharacter always means what you first thought it did.

To finish off this section, try the following: