Perl feature. Several operators take a delimited argument. The best-known of these are probably tr///, m// and s///, but the q*// operators (qw//, qq//, q//, qx//) also let you choose. Of course, if your argument needs to include a slash (`/') you're in trouble, and you'll have to backwhack it (or the argument will end). This is somewhat common in the UN*X world, and leads to the dreaded leaning toothpick syndrome:

s/\/{2,}/\//g;    # remove doubled slashes from /path//to//file
tr/\/\\/\\\//;    # swap slash and backslash
Throw in a few literal pipes (`|') and the alternation operator, and you have a recipe for a headache.

Instead, Perl lets you pick your own delimiters for these operators. You can use any character around your arguments. Some characters naturally come in pairs: (), , {}, <>, and Perl uses these pairs. To avoid LTS, do this:

(You still need to backwhack your backslashes -- but you always have to do that).

Paired delimiters even nest, so you can say print qq{Nested {brackets}\n}; to print "nested {brackets}". This is really nice for printing code. And since you have separate opening and closing delimiters, you can put whitespace between the two parts of a s(...) {...}, which is even nicer:

s {/{2,}} {/};

Log in or register to write something here or to contact authors.