in reply to print backslash in variable
You could initialise your variables using the \x?? hexadecimal character values to avoid confusion.
$ perl -E ' say for ( qq{a\x5cb}, qq{a\x5c\x5cb}, qq{a\x5c\x5c\x5cb}, qq{a\x5c\x5c\x5c\x5cb}, );' a\b a\\b a\\\b a\\\\b $
I hope this is helpful.
Update: Another way would be to use chr.
$ perl -E ' > @arr = map { q{A} . do { chr 0x5c } x $_ . q{B} } 1 .. 4; > say for @arr;' A\B A\\B A\\\B A\\\\B $
Cheers,
JohnGG
|
|---|