c:\@Work\Perl>perl -wMstrict -le "use Data::Dump qw(dd); ;; my @filelines = ( '\102\105\105 B', 'nbsp \040', '\130 EKS', '\132 ZEE', ); ;; my %search_terms = map split, @filelines; ;; my %xlate = map { eval(qq{ qq{$_} }) => $search_terms{$_} } keys %search_terms ; dd \%xlate; ;; my ($search) = map qr{ $_ }xms, join ' | ', reverse sort keys %search_terms ; print $search; ;; my $s = 'the BEErownbspfoX >nbsp< the laZy dog'; print qq{'$s'}; ;; $s =~ s{ ($search) }{ qq{ qq{$xlate{$1}} } }xmsgee; print qq{'$s'}; " { BEE => "B", nbsp => "\\040", X => "EKS", Z => "ZEE" } (?^msx: nbsp | \132 | \130 | \102\105\105 ) 'the BEErownbspfoX >nbsp< the laZy dog' 'the Brow foEKS > < the laZEEy dog'