my $dir = "/mnt/home/volume/"; my $i = 0; ++$i until mkdir "$dir$i"; ## $i contains the dir successfully created