if ($a=~ s/'/\\'\\'/g) { # there were quotes in $a # do what you want to }