Perl str_replace

$s =~ s!\Q$search!$replacement!g;

\Q will quote a string until \E (if \E is ommitted will quote the whole string). You need to quote the string because s/// uses regexp;

You can view more Perl written in PHP here.

Leave a Reply