in reply to Re^3: Perl Permissions
in thread Perl Permissions

You might get a "permission denied" error if the directory for the target doesn't exist. In other worlds, if in
$newlocation = "/perl/ass/$folder[$N]/$logfiles[$hour]";
the directory
$newlocationdir = "/perl/ass/$folder[$N]";
doesn't exist.

You can use mkpath in File::Path (a standard module, so you should already have it on your system) to create it, just in case, before moving the file:

use File::Path 'mkpath'; use File::Copy 'move'; mkpath "/perl/ass/$folder[$N]"; move($oldlocation, $newlocation) or die "File cannot be moved: $!";
Note that there is no error checking for mkpath, because it may fail if the directory already exists. It doesn't matter. But the directory should exist after mkpath, so a test with -d "/perl/ass/$folder[$N]" would not be a bad idea.