while (){ chomp; $tag = $_; if (grep {$tag == $_} 500..503,531,532) { print "$tag\n"; } }