in reply to Re^5: How to capture error messages...
in thread How to capture error messages...

Oh, sorry. I didn't notice that.

In that case, let me modify the above code like this (untested):

my $resultLdapSearch; { defined(my $pid = open my $P, "-|") or die "error forking ldapmodify: +$!"; if (!$pid) { open STDERR, ">&STDOUT" or die "error dup2ing stdout to stderr"; exec "ldapmodify", "-h", $ldap_server, "-D", "cn=Directory Manager +", "-w", $dir_mgr_pwd, "-f", $ldap_modify_file or die "cannot exec ldapmodify: $!"; die; # just to be sure } local $/ = undef; defined($resultLdapSearch = <$P>) or die "error reading from pipe: $!"; close $P or die $! ? "error closing pipe: $!" : "ldapmodify exitted with a nonz +ero exit status: $?"; }