my %revHash= reverse %dictHash; my @revKeys=keys(%revHash); foreach(@revKeys) { $_[1]=~s/$_/$revHash{$_}/g; }