mkdir dir1 dir2 touch dir1/f{1,2} #### foreach (1,2,3,4) { print "dir1\n" if glob("dir1/f*"); print "dir2\n" if glob("dir2/f*"); } #### print "dir1\n" if glob("dir1/f*"); print "dir2\n" if glob("dir2/f*"); print "dir1\n" if glob("dir1/f*"); print "dir2\n" if glob("dir2/f*"); print "dir1\n" if glob("dir1/f*"); print "dir2\n" if glob("dir2/f*"); print "dir1\n" if glob("dir1/f*"); print "dir2\n" if glob("dir2/f*");