Harden string replacement by quoting metachars.

Source: http://www.perlmonks.org/?node_id=98357