in reply to Check last character of a string
$x =~ s/([^\\])$/$1\\/ [download]
perl -wMstrict -le "for (@ARGV) { print; s{ (?<! \\) $ }'\\'xms; print } " with\ sans with\ with\ sans sans\ [download]