I want to create folder using perl where, in the same folder, a perl script exists. I created FolderCreator.pl which requires an input parameter of folder name.
unless(chdir($ARGV[0]){ # If the dir available change current , unless
mkdir($ARGV[0], 0700); # Create a directory
chdir($ARGV[0]) or die "can't chdir $ARGV[0]\n"; # Then change or stop
}
This worked fine only if we call the scipt, in the same folder where it resides. If it is called in another folder, if doesn't work.
Eg.
.../Scripts/ScriptContainFolder> perl FolderCreator.pl New
.../Scripts> perl ./ScriptContainFolder/FolderCreator.pl New
First one is working fine but second one doesn't. Is there way create these folders?
pwd; chop($pwd); $path = substr($path, length($pwd)); to get the relative path and also tried mkpath($path.$ARGV[0]) but it gives error "mkdir /Darshana: Permission denied at ./Darshana/scripts/FolderCreator.pl line 25"