in reply to if ... elsif ... else

Just a quick thought:

foreach my $i ( $from .. $to ) { next if $i%2 || $i%3 || $i%4 || $i%5; say $i; }

Works because zero is false and any other number is true (Update: I admit that's a slight simplification, but appropriate in this context. See also Truth and Falsehood).

Haven't yet given any thought to whether there are any mathematical properties that might make testing all those numbers unnecessary.

Update: Or even say for grep {!($_%2||$_%3||$_%4||$_%5)} $from .. $to; (although I suspect this might be a bit slower than the above, untested)

Update 2019-08-17: Updated the link to "Truth and Falsehood".