in reply to grouping consecutive integers

Because you initialise $previous to 0, the results will be incorrect if the lowest number in the list is 1. I'd avoid that problem by using undef to signal that there is no previous value:

my $previous; ... if (defined($previous) && $previous == $number - 1) { $table{$base}++; } else { ... }

Hugo