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.

In reply to If I Want Backslashes, I'll Ask For Backslashes by tadman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.