foreach my $k (keys %hash){ $hash{$k} =~ s/,(?! )/, /g; }