Here's a couple that I've done:
$line =~ s/\\/\\\\/g; # Replaces "\" with "\\"
$line =~ s/'/\\\'/g; # Replaces "'" with "\'"
$line =~ s/\//\\/g; # Replaces "/" with "\"
Now, nothing like above.. but I was still proud of my little work. I'm not a guru yet