The regular expression
has a mechanism for specifying which delimiter you would
prefer, such that the regular slash character can be used
within it to no ill-effect.
I am curious if there was a similar mechanism
for quotation, such that backslashes are not special in
anyway way. I expected
qq to operate this way, since
it is quite like a regular expression in terms of style,
but in fact, it does not even come close:
$foo = qq[\\something]; #1
$foo = qq!\\something!; #2
I'd expect that in either case, the quotations are not
special. Even within here-documents, the same problem
persists, with backslashes having special meaning:
$foo = <<END;
\\something
END
However, by some curious twist, this works as I would like:
$foo = <<'END';
\\something
END
Which seems to be an internal inconsistency with respect
to the way the functionality of the single quote is portrayed.
There is the "expanding backslash" problem which I have been
hit with in the past, where by every iteration of some
program you require more and more backslashes to get the
job done. One case was a YACC program that wrote a C
program which wrote some Perl, which in turn wrote some
JavaScript. At the very beginning you needed
something like eight backslashes to put in a single one in
the final product. Of course, if you miscounted, you
could break the thing horribly with only 7 or an extra one.