PERL Script : problems with mkdir and chdir -
checkandcreatedirectory(); movefiles(); sub checkandcreatedirectory { $dirname = "launchpad/config/com/adobe/granite/auth/saml/samlauthenticationhandler"; @folders = split /\/|\\/, $dirname; map { mkdir $_; chdir $_; } @folders; } sub movefiles { $source_dir = "samlauthenticationhandler"; $destination_dir = "launchpad/config/com/adobe/granite/auth/saml/samlauthenticationhandler"; opendir(my $dir, $destination_dir) || die "can't opendir $source_dir: $!"; move("$source_dir", "$destination_dir") or die "fail : unable add config -> $!"; }
checkandcreatedirectory() , movefiles() subroutines running fine sepaerate script when tried run in same script throws error : no such file or directory
can please me in figuring out issue? there issue
map { mkdir $; chdir $; } @folders;
?
the issue chdir
of subdirectories of checkandcreatedirectory
never return started, when call movefiles
, in wrong place , cannot find $destination_dir
.
i simplify script this:
use warnings; use strict; use file::copy::recursive qw( dirmove ); use file::path qw( make_path ); $saml_handler_path = 'launchpad/config/com/adobe/granite/auth/saml/samlauthenticationhandler'; make_path $saml_handler_path or die "unable create path '$saml_handler_path' : $!"; $source_dir = "samlauthenticationhandler"; $dest_dir = $saml_handler_path; dirmove( $source_dir, $dest_dir ) or die "unable move $source_dir $dest_dir : $!";
Comments
Post a Comment