>>26
irb(main):003:0> puts "\\".sub(/\\/, '\\\\')\=> nilirb(main):004:0> "\\".sub(/\\/, '\\\\')=> "\\"
Ahem :O. puts interprets the string exactly the way it should. The stray "\" at the end is cut off as it doesn't seem to escape anything.
puts