for (0..18, 20..28, 30..38) { my $filename = sprintf('out-02-%02d.txt', $_); ... }