You already test the result of
move, you just don't change what your log writes. You also duplicated code in both branches of the
if. I think it ought to go something like this:
if (not -e $newlocationlocation) {
my $perm = 775;
mkdir ($newlocation,$perm) or &on_err("Error making Directory\n");
}
if (move ($oldlocation,$newlocation)) {
print LOGFILE "$theTime,moved,$oldlocation,$folder\n";
}
else
{
warn "Failed to move to folder";
print LOGFILE "$theTime,failed to move,$oldlocation,$folder\n";
}
Caution: Contents may have been coded under pressure.