in reply to Auto-increment wraps at 12

That code doesn't run stand alone so I've added a little support code. The result performs as I'd expect:

use warnings; use strict; my $onlyUse = 0; my @unitRow; my $csr2 = bless {count => 0}; my %seen; while (my @unitRow = $csr2->fetchrow) { my $unit = $unitRow[1]; unless ($seen{$unit}) { $seen{$unit}++; $onlyUse++; print " $onlyUse "; next; } } sub fetchrow { my $self = shift; return () if $self->{count} > 20; return (0, ++$self->{count}); }

Prints:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 + 21

Maybe you should show us some code that can be run and that reproduces your problem?

It seems likely that the while loop is run multiple times when in the larger context of your code.


Perl is environmentally friendly - it saves trees