When I preform an LDAP search like so
my $mesg = $ldap->search(
base => "$dn",
scope => 'base',
filter => '(objectClass=*)',
attrs => ['member'],
);
Should my script just log if $mesg->{resultCode} is not zero, or should by script log and die on not zero?
This is entirely up to the intended flow of your program – there isn’t a general “should” or “should not”.
If the code that follows depends on the search and is meaningless without it, you may die, otherwise you may skip the error and try to recover somehow.
One of the Unix principles, however, suggests that generally a program should fail as early as possible:
Rule of Repair: When you must fail, fail noisily and as soon as possible.