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