... chomp; $hash {$_} ++; } foreach (keys %hash) { $hash{$_}+= $pbxex-1; print PBXNUM1 "$_$hash{$_}\n"; }