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 );