I have attempted to explain my question with 2 examples using 'some\text' and "some\text" both of which get stored as I understood they should. However, 'some\\text' and "some\\text" don't behave as you would expect and are NOT stored with the same rules as the first case because in the first case, the compiler sees the single quotes and stores the characters correctly by pushing an additional '\' to the PV array as it should. What is going wrong, however, is the case when it sees a second '\' in the literal case, and doesn't push another '\' onto the PV.
use Devel::Peek; # literal case - PV's are the same $txt = 'some\text'; print "Case 1 'some\\text': $txt\n-------\n"; # PV gets an extra '\' pushed on it. Dump($txt); $txt = 'some\\text'; print "\nCase 2 'some\\\\text: $txt\n-------\n"; #PV does NOT get an extra '\' pushed on to it Dump($txt); # quoted case - PV's handle '\' as expected $txt = "some\text"; print "\nCase 3 \"some\\text\": $txt\n-------\n"; Dump($txt); # $txt = "some\\text"; print "\nCase 4 \"some\\\\text\": $txt\n-------\n"; Dump($txt);
If you actually try these examples, then you can see for yourself how the scalars are getting stored.

Nuff said. I will ask the perl porters from here.

In reply to Re^6: Escaping multiple escape chars by JamesNC
in thread Escaping multiple escape chars by JamesNC

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.