in reply to Creating Multiple Empty Directories with Perl

With File::Path:

   perl -MFile::Path -e 'mkpath([map { "dir$_" } (1 .. 20)])'

Or without:

   perl -e 'system("mkdir dir$_") for (1 .. 20)'

-sam

Replies are listed 'Best First'.
Re^2: Creating Multiple Empty Directories with Perl
by ikegami (Patriarch) on Sep 28, 2005 at 06:37 UTC

    Why are you using system? Perl has a mkdir function.

    Also, using mkpath is overkill if all directories are being created at the same level.

      You know, I asked myself the same question when I saw the other replies. I guess I forgot it was there! I always use File::Path out of laziness. Who wants to worry about how many levels need to be created?

      -sam

        True. Then the following would suffice:

        perl -MFile::Path -e 'mkpath("dir$_") for 1..20'