From: Jose O. <JAO...@lb...> - 2001-03-23 14:30:08
|
I generally use the "if..." type constructions regardless of the programming language I am using. Thank you one and all. John Berthels wrote: > > $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 |