Jason Bertoch wrote:

> My Perl skills are weak at best...would someone be willing to help me with the
> syntax to add a debug line to my filter that logs the number of MIME parts in
> each message processed?

There's no easy way to pull that out of the MIME::Parser.  The variable
$parser is a "my" variable in the private do_scan function.  This
function (untested!) called on the $entity from filter_end might do
the trick:

sub count_parts
{
        my ($entity) = @_;
        return 1 unless $entity->is_multipart;

        my $count = 1; # The multipart container is itself a part
        foreach my $part ($entity->parts) {
                $count += count_parts($part);
        }
        return $count;
}

It's a recursive function that may be somewhat slow on large or deeply-nested
MIME messages.

Regards,

David.
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to