Bad Ynfo said:
Hi,
In perlop, it reads:
'', q//
The only interpolation is removal of \ from pairs \\.
So how can I assign '\\foo\bar' to a scalar without having to say
'\\\\foo\bar'?
Why do you think you want to assign '\\foo\bar' to a scalar without
having to say '\\\\foo\bar'?
That is NOT a rhetorical question. This sounds like an XY Problem to me,
we could give a much better answer if we knew what the "Y" was...
What is it that you are ultimately trying to accomplish?
If those data are paths, then did you know that '//foo/bar' will
work in most cases?
How are you using these strings?
If you can switch to sensible slashes, your whole problem goes away
(which is what makes those silly slashes silly).
Sure, but the cure is MUCH worse than the disease.
What is your objection to backslashing backslashes in literal strings?
Here are some examples:
$_ = chr(92) . chr(92) . 'foo' . chr(92) . 'bar'; # works for ASCII
$_ = "@{[chr(92)]}@{[chr(92)]}foo@{[chr(92)]}bar"; # works for ASCII
my $bs = chr(92); # works for ASCII
$_ = "$bs${bs}foo${bs}bar";
$_ = '//foo/bar';
$_ =~ tr#/#\\#;