Can I do the same again? Can I say that "I want 30 folders, from AB0001 up to AB0030; also 50 folders, from BC0001 up to BC0050" and so on?Something like this:
If that looks like what you want, replace print with make_path (and remove \n, obviously). Note that make_path doesn't understand ~ (tilde), but you can use $ENV{HOME} instead of tilde.use strict; use warnings; my @dirs = ( make_seq( 'AB', 6, 1, 30 ), make_seq( 'BC', 6, 1, 50 ), ); for my $dir (@dirs) { for my $subdir ( make_seq( 'S', 6, 1, 100 ) ) { print "$ENV{HOME}/$dir/$subdir\n"; } } sub make_seq { my ( $prefix, $total_length, $from, $to ) = @_; my $length = $total_length - length($prefix); my $format = "${prefix}%0${length}d"; return map sprintf( $format, $_ ), $from .. $to; }
In reply to Re: make_path for creating directory tree
by Anonymous Monk
in thread make_path for creating directory tree
by fasoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |