in reply to Re: Counting within an array
in thread Counting within an array

In order to meet the posted spec (output on every line), you can move the print statement into the while loop:

my %hash; while (<MYINPUTFILE>) { chomp; $hash{$_} ++; print "$_$hash{$_}\n"; }

Replies are listed 'Best First'.
Re^3: Counting within an array
by ddrew78 (Beadle) on Nov 30, 2010 at 14:12 UTC
    That works like a charm, thank you very much.