I have a horrible feeling nothing got done about this due to combined
craziness around September and the end of the year.

So I'm forwarding it to the Perl Email Project mailing list to get 
things moving again.

Apologies in the (horrific) delay :(

Simon


----- Forwarded message from Tom Brown <[EMAIL PROTECTED]> -----

Date: Thu, 23 Sep 2004 03:09:22 -0500
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
From: Tom Brown <[EMAIL PROTECTED]>
Subject: Email::MIME interface
Organization: Society for the Elimination of Excess Superfluous Text in 
Internet Header Lines (SEESTIHL)
User-Agent: Mutt/1.5.4i

Casey and Simon,

Here is a mail I sent to [EMAIL PROTECTED] According to
http://use.perl.org/~petdance/journal/ you now maintain much of
Email:: Thank you for volunteering!

Simon Cozens wrote in the Email::MIME 1.8 notes:
> This is an alpha release, designed to stimulate discussion on the
> API,

I'm not sure what advantage parts() yeilds. I am writing a function
which extracts all the text in a message. My first attempt went as
follows:
sub get_mime_text
{
  my $this = shift;
  my $text = '';
  my @subparts = $this->parts;

  if( $this->content_type =~ m#^text/#i ) {
    $text = $this->body;
  } else {
    foreach my $part ( @subparts ) {
      # Recursively look at each part
      $text .= get_mime_text( $part );
    }
  }

  return $text;
}

The problem is that a non-text part without subparts will recurse
forever. This is easily fixed by making sure the content_type is
mulitpart or message before making the recursive call.

I would like to propose removing parts() and creating subparts().
I imagine other people wanting to descend a tree of MIME parts.
subparts() would make this trivial. People who still want the old
functionality can use
my @parts = $mime->subparts or $mime;

Currently 
scalar($threesubparts->parts())== 3 
scalar($twosubparts->parts())  == 2 
scalar($onesubparts->parts())  == 1 
scalar($zerosubparts->parts()) == 1  (3,2,1,1? Why isn't this 0?)
showing that $zerosubparts is a logical special case.

Implementing subparts() takes a few lines less in MIME.pm than parts,
and it adds at most two words to the caller. I can create a patch if you
would have interest in using it.

subparts will also avoid the memory leak issue reported by
http://rt.cpan.org/NoAuth/Bug.html?id=7007


Tom

-- 
28 70 20 71 2C 65 29 61 9C B1 36 3D D4 69 CE 62 4A 22 8B 0E DC 3E
mailto:[EMAIL PROTECTED]
http://thecap.org/

----- End forwarded message -----

-- 
giant hell goose vs. alien space bats - FIGHT!

Reply via email to