in reply to Single quoting weirdness
It looks odd, but it is correct behaviour. \ is a meta-character for escaping, but in single quoted strings the only thing it escapes is ' (which allows you to embed a ' in a single quoted string without having to use the q{} syntax, or itself). Nothing else is quotable.
So in the second line, \+, + is not magical, does not have to be quoted, so \ has no effect, is not consumed, and thus \+ is emitted.
In the third line, \\+, \ escapes the following \, so \+ is emitted, and so on for the forth line.
You might want to look at S_scan_str in toke.c for far more than you ever wanted to know about how perl scans strings.
The most straightforward way of writing your code would be to double up each \ you want to print:
perl -e "print join(qq(\n),('+','\\+','\\\\+','\\\\\\+')),qq(\n)" # or, more concisely perl -le "print $_ for qw/+ \\+ \\\\+ \\\\\\+ \\\\\\\\+/"
|
|---|