in reply to Transforming "\r\n" to '\012\015'
Adding to the ?above —
A generic solution must escape the escape character also, otherwise the transformation isn't reversible.
{ my %T = ("\n" => "\\n", "\r" => "\\r", "\\" => "\\\\"); sub escape { s/[\r\n\\]/$T{$&}/g for @_ } }
|
|---|