I have one problem in perl script development.

I have big logic executing in script and finally should save in directory structure specified.

directory structure is created at runtime dependind on user runtime arguments by argv

my MAKEPATH.the script works if i gave destination directory as

/home/abhinav/direc1/ (/home/abhinav/) is my root directory.

But if i give /proj/xy/debug/ means directory not creating and giving errors like

perrmission denied.Bur i PWD means it is cmng like /home/abhinav/

so i was in my directory only bur not creating.

That was error please try to help me

In your example does /proj/xy already exist? What error are you getting?


Actually /proj/xy it was not there.Depending on user argv at runtime

i was creating by using makepath.

Post the bit of the code that is failing

This was the code i was trying

if (! -d $dp1)
 mkpath($dp1) or die "Failed to create $dp1: $!\n";

Where $dp1=/proj/xy/z/

this was the error
mkdir /proj/xy: No such file or directory at tmp.pl line 47

but i was not getting this erroe if i gave directory as

/home/abhinav/proj/xy/z/ where /home/abhinav/ is my root directory

which one you are using?

1. mkdir
2. mkpath

mkdir : Creates directory for first level only.
mkpath : Creates directory for Nth level
if you are using mkpath you must declare the 'File:: Path' module.

For your example you tried create more than one level. So must use mkpath and aware of the permission.

I assume you want to create directory in your destination path.
If you use the mkpath function, You must provide the fullpath.
You concat destination directory with your runtime directory.

Try the below code in your file

use File::Path;

### Declare your destination directory

### get the runtime directory

if (! -d “$dest/$dp1”)
 mkpath(“$dest/$dp1” or die "Failed to create $dest/$dp1: $!\n";

What user are you doing this as? If you're trying to create a directory in the root directory you need to be root, otherwise it won't work as the permissions for the root directory are normally drwxr-xr-x

Shouldn't the mkdir be "./proj/xy" or "proj/xy" if you wish to create within your home directory? "/proj/xy" would seem to try to create the directory from the root.