in reply to Re: make_path for creating directory tree
in thread make_path for creating directory tree
If I use an integrated loop, like so#/bin/perl/ use strict; use warnings; use File::Path qw(make_path); my @structs; my $structs; my @molecs; my $molecs; my @steps; my $steps; # Parent structure directory. @structs = ( dir_tree( 'struct', 7, 1, 1), dir_tree( 'struct', 7, 2, 2 ), # dir_tree( 'struct', 7, 3, 3 ), # dir_tree( 'struct', 7, 4, 4 ), # dir_tree( 'struct', 7, 5, 5 ), # dir_tree( 'struct', 7, 6, 6 ), ); # Subfolder molecule directory. @molecs = ( dir_tree( 'AB', 6, 1, 1 ), dir_tree( 'BC', 6, 1, 1 ), # dir_tree( 'XZ', 6, 1, 4 ), # dir_tree( 'XY', 6, 1, 4 ), # dir_tree( 'QU', 6, 1, 4 ), # dir_tree( 'QE', 6, 1, 4 ), ); # Subfolder steps directory. @steps = ( dir_tree( 'S', 6, 1, 2 ), ); for $structs (@structs) { make_path "/media/RAIDstorage/home/results/$structs"; } for $molecs (@molecs) { for $steps (@steps) { make_path "/media/RAIDstorage/home/results/$structs/$molecs/$s +teps"; } } # Define subroutine here. sub dir_tree { my ( $name, $total_length, $from, $to ) = @_; my $length = $total_length - length($name); my $format = "${name}%0${length}d"; return map sprintf( $format, $_ ), $from .. $to; }
I get no errors but the wrong directory tree. That way, all $molecs are added in both $structs, when I want AB to go only in $struct1 and BC to go only in $struct2. I also tried using two different subroutines, like sub1 and sub2, but it also gave me the same error, "uninitialized value". Is the answer the two different subroutines, only I did it wrong? Any hints as to what I'm messing up? Thank you all!for $structs (@structs) { for $molecs (@molecs) { for $steps (@steps) { make_path "/media/RAIDstorage/home/results/$structs/$molecs/$s +teps"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: make_path for creating directory tree
by fasoli (Beadle) on Jan 22, 2016 at 16:54 UTC | |
by poj (Abbot) on Jan 22, 2016 at 17:06 UTC | |
by Anonymous Monk on Jan 22, 2016 at 17:54 UTC | |
by fasoli (Beadle) on Jan 22, 2016 at 18:06 UTC | |
by poj (Abbot) on Jan 22, 2016 at 18:26 UTC |