use strict; use warnings; # my ($from, $to) = split / /, "30 40"; my $line = <>; chomp $line; my ($from, $to) = split / /, $line; for my $n ($from .. $to){ if ($n =~ /3/ || $n % 3 == 0 ){ print $n, "\n" } }