perl problem - why isn't 'die' being called?

last week i started learning perl, so have limited skill and knowledge.

why isn't 'die' being called and the script exiting before the 'directory created' line?

if (! -d "$logdir") {
    system "mkdir -p $logdir" || die print "\nERROR: release log directory creation failed - $logdir: $!\n";
    print "\nINFO: Directory created - $logdir\n";
}

the result:

mkdir: "/build/cm_test_sharee/release_logs/crm/crmuat": Permission denied

INFO: Directory created - /build/cm_test_sharee/release_logs/crm/crmuat

thanks in advance,

matt

The system call itself will have to return failure in order for die to be called.
This happens only when the system cannot cannot for a new process.

system returns a value like what wait returns.

consider using backticks - ie,

`mkdir -p $logdir 2>&1` 

Perl and shell have opposite ideas about true and false.

$true;echo $?
0
$false;echo $?
1
$perl -e 'if(0) {print "true\n"} else {print "false\n"}'  
false
$perl -e 'if(1) {print "true\n"} else {print "false\n"}'
true

ah that makes sense - both replies.

thanks for your help,

matt

from the man pages:

The return value is the exit status of the program as returned by the wait call.
To get the actual exit value, shift right by eight (see below). See also exec.
This is not what you want to use to capture the output from a command, for that you should use merely backticks or qx//, as described in "`STRING`" in perlop.
Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason).

see system - perldoc.perl.org