Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.15.198.69
# Copyrights 1995-2016 by [Mark Overmeer <perl@overmeer.net>].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
use strict;
package Mail::Filter;
use vars '$VERSION';
$VERSION = '2.18';
use Carp;
sub new(@)
{ my $class = shift;
bless { filters => [ @_ ] }, $class;
}
sub add(@)
{ my $self = shift;
push @{$self->{filters}}, @_;
}
sub _filter($)
{ my ($self, $mail) = @_;
foreach my $sub ( @{$self->{filters}} )
{ my $mail
= ref $sub eq 'CODE' ? $sub->($self,$mail)
: !ref $sub ? $self->$sub($mail)
: carp "Cannot call filter '$sub', ignored";
ref $mail or last;
}
$mail;
}
sub filter
{ my ($self, $obj) = @_;
if($obj->isa('Mail::Folder'))
{ $self->{folder} = $obj;
foreach my $m ($obj->message_list)
{ my $mail = $obj->get_message($m) or next;
$self->{msgnum} = $m;
$self->_filter($mail);
}
delete $self->{folder};
delete $self->{msgnum};
}
elsif($obj->isa('Mail::Internet'))
{ return $self->filter($obj);
}
else
{ carp "Cannot process '$obj'";
return undef;
}
}
sub folder() {shift->{folder}}
sub msgnum() {shift->{msgnum}}
1;
|