Thursday, January 24, 2008

Perl Tricks

Quote and Quote-like Operators ------------------------------While we usually think of quotes as literal values, in Perl theyfunction as operators, providing various kinds of interpolating and pattern matching capabilities. Perl provides customary quote characters for these behaviors, but also provides a way for you to choose your quote character for any of them. In the following table, a {} represents any pair of delimiters you choose.

Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes
* qw{} Word list no
// m{} Pattern match yes
* qr{} Pattern yes
* s{}{} Substitution yes
* tr{}{} Transliteration no (but see below
'<<'EOF here-doc yes

* * unless the delimiter is ''.

No comments: