in reply to how to create folders

I would use glob to find the files that exist in the directory, and extract the numeric component (or 0 if there's none). Then sort those numbers in descending order, and take the first one. That gives us our highest directory.

It is then a simple matter of programming to use File::Path and create the ten new directories, adding steps of a thousand to the highest number, and prepending the stem of the directory.

In fact, minus a certain amount of fluff, it only takes two statements: one to find the highest, and one to create the directories:

use strict; use warnings; use File::Path 'mkpath'; my $stem = 'object'; my $highest = ( sort {$b <=> $a} map { /(\d+)$/ ? $1 : 0 } glob("$stem*") )[0]; mkpath( [map {$stem . ($highest + $_*1000) } 1..10], 1, # verbose 0777 # full access for everyone );

• another intruder with the mooring in the heart of the Perl