$okvalues = "0 20 34 23 5"; for($i = 1; $i < 100; $i++) { if($okvalues =~ m/$i/) { print "$i\n"; } }