my $onlyUse = 0; while (my @unitRow = $csr2->fetchrow) { my $unit = $unitRow[1]; unless($seen{$unit}) { $seen{$unit}++; $onlyUse++; print " $onlyUse ";next; } }