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