From: John B. <joh...@ne...> - 2001-03-23 10:40:57
|
> $mesg->code && die $mesg->error; > > That would be a common perlism for do the first part, and if it succeeds, > then do the second part. You can also do that in UNIX shell. Yes, but it relies on the 'return code of zero is success' convention. The code is equivalent to: # Sorry...I like brackets on function/method calls if( $mesg->code() == 0 ) { die $mesg->error(); } The ->code() method returns the LDAP result code of the operation the $mesg is the result of. LDAP follows the UNIX/C convention of 'return 0 for success'. Note that this is the opposite of the convention used in perl, where functions and methods return a true value for success and a false value for failure. (Except for the system() call, which follows the Unix convention since it invokes a Unix command line (OK...or a WinNT command line)). So in perl you have the common idiom:: open FOO, "< foo" || die "ack : $!"; and there the '||' is replaced with a '&&' in the LDAP example code because of the different return convention. Yours pedantically, jb |