in reply to Re^2: Regex to dereferencein thread Regex to dereference
$str =~ s/(?<!\\)\\$/\\\\/; # match a backslash at the EOL # that isn't preceded by a backslash [download]
See perlre for more stuff like this.