use strict; use warnings; my @phrases=('(arf)71', 'p65(91)', 'H:223', 'Phospholipase A2 inhibitor', 'Phospholipase A2', 'Phospholipase', 'PLI-A', 'PLI-B', 'PLI'); my $string = join '|', map { quotemeta } @phrases; my $in = "(arf)71 p65(91) H:223 Phospholipase A2 inhibitor ( PLI ) , purified from the blood plasma of the Habu snake ( Trimeresurus flavoviridis ) , was separated into two distinct subunits , PLI-A and PLI-B"; my $out = "#(arf)71# #p65(91)# #H:223# #Phospholipase A2 inhibitor# ( #PLI# ) , purified from the blood plasma of the Habu snake ( Trimeresurus flavoviridis ) , was separated into two distinct subunits , #PLI-A# and #PLI-B#"; #while($in =~ s/(^|\s)($string)(\s|$)/$1#$2#$3/) {}; while($in =~ s/(^|\s)($string)(\s|$)/$1#$2#$3/g) { pos() = pos() - 1; }; print "success!!\n" if($in eq $out); print "in: $in\n"; print "out: $out\n";