http://qs321.pair.com?node_id=255756


in reply to Substitution Question

If you are doing this to insert the data in a database, I'd recommend making the problem go away by learning how to use placeholders. Look in Tutorials for guides on using DBI and placeholders.

Anyway, this regex should do what you want.

$artist =~ s/'/\\'/g;

You may also have to do substitutions for the escape character itself if it might ever appear in any of your strings.

90% of every Perl application is already written.
dragonchild