use Statistics::Descriptive; $stat = Statistics::Descriptive::Full->new(); $stat->add_data( split /,/, ); %f = $stat->frequency_distribution(4); $min = 0; for ( sort { $a <=> $b } keys %f ) { printf "[%d\t-%d\t] %d\n", $min, $_, $f{$_}; $min = $_ + 1; } __DATA__ 0, 12, 25, 38, 50, 62, 75, 88, 100 __END__ # prints [0 -25 ] 3 [26 -50 ] 2 [51 -75 ] 2 [76 -100 ] 2