for my $n (1..22,50,60,70,80,97) { my $path = sprintf "D:/DOWNLOAD/DISTRBTN/I01/B%02d/", $n; if (-e $path) { #... } }