in reply to How to automate construction of directories?

Sure you can. Let's assume the client list is in clients.txt, the subdirectory list in subdirectories.txt, one entry per line. You can read the clients like this:
open IN, '<', 'clients.txt' or die "Can't open file 'clients.txt': $!" +; @clients = <IN>; chomp @clients;
Idem for the subdirectories:
open IN, '<', 'subdirectories.txt' or die "Can't open file 'subdirecto +ries.txt': $!"; @subdirs = <IN>; chomp @subdirs;

Now, it's time to "multiply" the clients with the subdirectories, meaning combining each of one array with each of the other array, and create the subdirectories for each result.

Note that perl actually doesn't mind you trying to create a directory that already exists.

my $year = 2005; mkdir $year, 0755; foreach my $client (@clients) { $client =~ /(\d*)\d/ or next; # we need digits; my $range = "${1}0_${1}9"; -d "$year/$range" or mkdir "$year/$range", 0755 or die "Can't create directory '$year/$range': $!"; -d "$year/$range/$client" or mkdir "$year/$range/$client", 0755 or die "Can't create directory '$year/$range/$client': $!"; foreach my $subdir (@subdirs) { -d "$year/$range/$client/$subdir" or mkdir "$year/$range/$clie +nt/$subdir", 0755 or die "Can't create directory '$year/$range/$client/$subdir +': $!"; } }

Replies are listed 'Best First'.
Re^2: How to automate construction of directories?
by jdporter (Paladin) on Jan 05, 2005 at 22:13 UTC
    Good, but I'd simplify by using a module:
    use File::Path; my $year = 2005; for my $client ( @clients ) { my( $clump ) = $client =~ /(\d*)\d/ or next; # we need digits; my $range = $clump.'0_'.$clump.'9'; mkpath([ map "$year/$range/$client/$_", @subdirs ]); }
    (Untested)