Or create a hash lookup for your range and then compare it to the numbers. This is probably the best method if your data file is very large and/or your range is large.
$h{$_} = () for (500, 501, 502, 531, 532);
while (<DATA>) {
chomp; print "$_\n" if exists $h{$_};
}
__DATA__
500
501
502
503
504
508
522
531
532
505