On Thursday 30 September 2004 18:50 CET Justin Mason wrote:
> Bob Apthorpe writes:
> > That should gracefully handle both SA 2.x and 3.x, correct?
>
> actually, it looks like we totally dropped the
> Mail::SpamAssassin::NoMailAudit module entirely.   When we were doing
> this, I suggested we leave a vestigial, empty module for that in 3.0.0 to
> avoid this problem, just so that the "use" line could still be used, but
> looks like I got outvoted :(   So the code has to be more complex,
> unfortunately.

I can just judge from the snippet below, but...

> At the head of the module where all the 'use' statements live...
> ----
>   use Mail::SpamAssassin;
>
>   use Mail::Header;
>   use Mail::Internet;
>
>   if ($Mail::SpamAssassin::VERSION < 3) {
>       eval { require Mail::SpamAssassin::NoMailAudit; };
>   } else {
>       eval { require Mail::SpamAssassin::Message; };
>   }
> ----

This should be enough:
----
  use Mail::SpamAssassin;

  use Mail::Header;
  use Mail::Internet;

  if ($Mail::SpamAssassin::VERSION < 3) {
      require Mail::SpamAssassin::NoMailAudit;
  }
----
Because Mail::SpamAssassin v3 already use()s ::Message so it's also 
available for the calling code.  And wrapping the stuff into eval()s 
doesn't make sense because require() (in contrast to use()) is scoped so if 
the block isn't reached, nothing will try to include ::NoMailAudit.

> Then later, once we've wrapped the text in fake mail headers to make
> a RFC822-compliant message...
> ----
>     # Make a M::SA object; point to custom configs
>     my $spamtest = Mail::SpamAssassin->new($self->{'sa_prefs'});
>
>     my $message =
>       Mail::Internet->new('Header' => $mailhead, 'Body' => $Rl_body);
>
>     # Fake up a mail message and stuff the comment in the body
>     if ($Mail::SpamAssassin::VERSION < 3) {
>         $self->{'_mail'} =
>           eval { Mail::SpamAssassin::NoMailAudit->new('data' =>
> [$message->as_string]); };
>     } else {
>         $self->{'_mail'} =
>           eval { $spamtest->parse ([$message->as_string]); };
>     }
> ----

The eval()s aren't needed here either.

>[...]

Cheers,
Malte

-- 
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
      <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
      <http://www.catb.org/~esr/faqs/smart-questions.html>

Reply via email to