logging $! with $r->log_error

Mark Copper <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
Hi all,

I stole this snippet years ago (and probably modified it improperly)
only to learn yesterday it has a serious problem:

   unless(open MAIL, "| /usr/sbin/sendmail -t -i -F'...' -f'...''"){
   $main::r->log_error("Couldn't open mail: $!");
   return DECLINED;
   }

namely this error:
   [Thu Dec 09 16:32:44 2010] [error] [client ...] Can't call method
"log_error" on an undefined value at ...

resulting in a 500 HTTP response (which I want very much to avoid).

I can just remove the offending "$!", of course, but is then I won't
get the error message when it *does* get set.

So my question: when "open" to a pipe does not return a process PID
and $! is not set, is there any other source of information regarding
what caused the error?

I'm pretty ignorant on this type of thing, so sorry if it's a stupid question.

Mark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.