my %hash; while ( ) { chomp; $hash{$_}++ and next if $_ > 5; print; } __DATA__ 3 7 9 1