In any quoted string ("", '', qq{}, q{}, etc.), a double backslash must be interpolated as a single backslash, because a backslash is used to escape the quoting character(s). This makes it possible to get the one character string \ and the two character string \', with '\\\'' and '\\', respectively.

I don't see what's wrong with having '\' mean \ and having '\'."'" or q<\'> mean \'. It's a little more typing, but personally if I was the creator of Perl I would sacrifice the special meaning of backslashes in single-quoted strings for more normality...oh well, I'll have to be content with a source filter or using here-docs. But...

Here-docs are the exception to this. One can always find a terminator, possibly several characters long, that doesn't appear within the string itself. <

This is something I've been thinking about. What if I'm quoting arbitrary user-supplied data in an eval()? I wouldn't want to remove any occurances of the here-doc terminator I was using -- that might upset users whose data contains my terminator. Even if the terminator is a long and rare word, there is still a chance of data/terminator clashing -- disallowing the terminator in the data seems very cargo-cult and wrong to me.

I guess the best here-doc terminator in this case would be a randomly-generated one...if only Perl had a qb// operator to quote an arbitrary number of bytes. (__DATA__ doesn't do what I want, since it is only one section. And if I want multiple sections, I need separators. The same exact problem all over again. Oh wait -- I could just store the number of bytes inside each section of the DATA. But then I have an evil arbitrary limit on how much data the user can supply. Unless I use BER encoded integers. Too much work for me.)


In reply to Re: Re: Re: Re: Re: DOS directory naming in PERL? by Anonymous Monk
in thread DOS directory naming in PERL? by phathead22

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.