for my $line (@lines) { while(my ($find, $replace) = each %ids) { s/$find/$replace/g } }