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 |
In reply to Re: Substitution Question
by pfaut
in thread Substitution Question
by Pacman34
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |