note
JamesNC
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.<br>
<code>
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);
</code>
If you actually try these examples, then you can see for yourself how the scalars are getting stored.<br>
<br>
Nuff said. I will ask the perl porters from here.
515642
515724