in reply to Re: how to create folders
in thread how to create folders

Excellent, I only had to make some small modifications, like:
my @dirs = grep { /object...000/ && -d "$_" } readdir(DIR); ... mkdir "object$highest"; chown $uid, $gid, "object$highest"; chmod 0777, "object$highest"; ...
Thanks so much!

Replies are listed 'Best First'.
Re^3: how to create folders
by bart (Canon) on Mar 28, 2007 at 10:43 UTC
    You could do it somewhat smarter and extract just the numbers:
    my @numbers = map /object(\d+)000/, grep -d, readdir(DIR);

    You can even directly pull out the highest number by using max out of List::Util:

    use List::Util 'max'; my $highest = max map /object(\d+)000/, grep -d, readdir(DIR);

    And using glob instead of readdir can help you wead out the unwanted files before trying to process them, if there's a lot of other stuff in the directory you may be not interested in:

    my $highest = max map /object(\d+)000/, grep -d, glob 'object???000';