Make directories and sub-directories with Perl?

  • Thread starter Thread starter martinthurn
  • Start date Start date
M

martinthurn

Guest
use strict;
use warnings;
use File::Path;
my $start = q{/home/wherever};
foreach my $letter ('A'..'Z') {
foreach my $number (1..5) {
mkpath qq{$start/$letter/$letter.$number};
}
}
 
Hello all. I'm new to making Perl scripts and I need to make a directory in my home folder, create 26 sub-directories in that folder labeled A through Z, then create 5 files in each sub-directory labled A.1 through A.7, B.1 through B.7, and so on. I'm looking for the best and most efficient way to do this with a bit of an explanation.
Correction. The files should be labeled A.1 through A.5, B.1 through B.5, .......
 
Back
Top