$ perle 'my %ent = qw{& & < < > >}; say "... < & > ..." =~ s/([&><])/$ent{$1}/gr' ... < & > ...