use YAML; my %count_per_100k; while () { my ($text, $count) = split; next unless $text =~ /gene/; $count_per_100k{int($count / 100_000)}++; } print Dump \%count_per_100k; __DATA__ ...