our %pkg_hash; local *pkg_hash = \%lex_hash; #### my $re = join '|', map quotemeta, keys %dict; s/($re)/$hash{$1}/g; #### use Regexp::List qw( ); my $re = Regexp::List->new()->list2re(keys %dict); s/$re/$hash{$1}/g;