my @thresh = ( 1000, 4000, 7000, 10000 ); my @bins; while () { my $val = ( split )[10]; next unless ( $val =~ /^\d+$/ ); my $i = 0; while ( $i < @thresh and $val > $thresh[$i] ) { $i++; } $bins[$i]++; }