use strict; use warnings; my %faclist; while () { chomp; $faclist{$_}++; } for (1 .. 5000) { if (exists $faclist{$_}) { print "Found $faclist{$_} of $_\n"; } } __DATA__ 1 1090 wibble 1 #### Found 2 of 1 Found 1 of 1090 #### print "Found $faclist{$_} of $_\n" for sort {$a <=> $b} grep {/^\d+$/} keys %faclist;