Skip Menu |

This queue is for tickets about the Mail-Thread CPAN distribution.

Report information
The Basics
Id: 31990
Status: new
Priority: 0/
Queue: Mail-Thread

People
Owner: Nobody in particular
Requestors: whynot [...] pozharski.name
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.41
Fixed in: (no value)



Subject: Mail::Thread hardly violates perlstyle, unbearable
Yes, I know. perlstyle (v.5.8.8) in the 3rd chapter from the bottom, B<just> recommends documenting code, but... Sir! That's unfair, first of all, to hide useful (and sometime critically useful) APIs behind curtains of C<__END__> (looking from the user's POV, the actual code is behind C<__END__>).
Subject: bugfix
diff -ur Mail-Thread-2.55.orig/Thread.pm Mail-Thread-2.55/Thread.pm --- Mail-Thread-2.55.orig/Thread.pm 2006-10-30 10:50:26.000000000 +0200 +++ Mail-Thread-2.55/Thread.pm 2007-12-29 22:33:21.000000000 +0200 @@ -541,6 +541,18 @@ Goes away and threads the messages together. +=over + +=item C<$Mail::Thread::noprune> + +Setting will prevent pruning empty (with no real message attached) nodes. + +=item C<$Mail::Thread::nosubject> + +Recovering threads based on C<Subject:> headers will be disabled. + +=back + =head2 rootset Returns a list of C<Mail::Thread::Container>s which are not the parents @@ -640,6 +652,31 @@ Calls the given callback on this node and B<all> of its children. +=head2 iterate_down($before, $after) + +That iterates depth-first through the thread. +Before any move C<$before> callback is invoked with the current node and the depth as parameters. +After iteration completes (that's not recursive iteration) C<$after> callback is invoked for B<all> nodes that have been found; +The depth is passed to C<$after> as a second parameter. + + # both arrays will be equal (w/ sorting left as an exercise) + # (actually, they'll be equal w/o sorting) + my(@one, @two); + $thread->iterate_down(sub { push(@one, shift(@_)->messageid(); }, undef); + $thread->iterate_down(undef, sub { push(@two, shift(@_)->messageid(); }); + + # that will taint all the thread, if any threaded mail has evil word + my $redflag; + $thread->iterate_down( + sub { + my $x = shift; + $x->message or return; + $x->message->get_body =~ m/\bbasic\b/i and $redflag++; }, + sub { + my $x = shift; + $x->message or return; + $redflag and $x->message->set_header('X-Spam-Status' => 25);}) + =head1 DEBUGGING You can set $Mail::Thread::debug=1 to watch what's going on.