in reply to SLOW DOWN, you move too fast.....

First, your code would be better written as:
my $num_keys = keys %output; print "$num_keys in output\n"; for my $key (keys %output) { print "$key,$output{$key}\n"; }
I would ask how you are measuring the number of lines printed. The speed with which it is printed shouldn't have anything to do with the total amount of output though buffering may be an issue depending on how you are counting. More information is needed.

Cheers - L~R