# Determine the size of the array so we hit everything my $array_no = scalar(@allDACDirs); for( my $i = 0; $i < $array_no; $i++) { my $curr_dir; my $entry; # Read the array and populate foreach $entry (@{$allDACDirs[$i]}) { # Review value whether its a dir or file my($chk_val, $filename) = split(/:/,$entry); # m means we need to make a new root directory if ($chk_val eq "m") { mkdir("$location/$filename",0755) or warn "Could not mkdir: $!\n"; $curr_dir = "$location/$filename"; } # d means a directory under root (like bin or lib) elsif ($chk_val eq "d") { mkdir("$curr_dir/$filename",0755) or warn "Could not mkdir: $!\n"; } # f means a file has to be made elsif ($chk_val eq "f") { # If there is a , we need a sub_dir, then make # file in that directory if ($filename =~ /,/) { my($dir_name, $file) = split(/,/,$filename); if (!-d "$curr_dir/$dir_name") { mkdir("$curr_dir/$dir_name",0755) or warn "Could not mkdir: $!\n"; } # If file exists in current directory then copy if (-e "$local_dir/files/$file") { copy("$local_dir/files/$file", "$curr_dir/$dir_name/$file") or die "Could not copy $filename: $!\n"; } else { # Else create the shell for the file open(FD,">$curr_dir/$dir_name/$file") || die "Could not make $file: $!\n"; } } else { # If file exists in current directory then copy if (-e "$local_dir/files/$filename") { copy("$local_dir/files/$filename", "$curr_dir/$filename") or die "Could not copy $filename: $!\n"; } else { # Else create the shell for the file open(FD,">$curr_dir/$filename") || die "Could not make $filename: $!\n"; } } } } }