in reply to
Re^5: Escaping multiple escape chars
in thread Escaping multiple escape chars
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.
# 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.
$txt = 'some\\text';
print "\nCase 2 'some\\\\text: $txt\n-------\n";
#PV does NOT get an extra '\' pushed on to it
# quoted case - PV's handle '\' as expected
$txt = "some\text";
print "\nCase 3 \"some\\text\": $txt\n-------\n";
$txt = "some\\text";
print "\nCase 4 \"some\\\\text\": $txt\n-------\n";
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.