WISE ONES,
I want to use to parse & process all (242) message in an inbox.
I suspect it is something simple, but I can't seem to make it work for me.
Please point me in the right direction.
TIA!
#!/usr/bin/perl -w # use MIME::Base64 (); use MIME::Parser; #my $raw_file = "/tmp/bcm"; my $raw_file = "/var/spool/mail/schering"; # the file above has 242 messages in it. open(RAW,$raw_file); my $msg_cnt = 0; my $line_cnt = 0; my $msg_start = -1; my ($subject, $pdf_name, $decoded); $subject = "blank"; my ( $line, $pdf_start, $pdf_close ); $pdf_start = 0; $pdf_close = 0; ### Create parser, and set some parsing options: $parser = new MIME::Parser; $parser->output_under("/tmp/mimemail"); # while ( <RAW> ) { $line = $_; $line_cnt++; $msg_start = index( $line,"From "); if ( $msg_start == 0 ) { $msg_cnt++; # $head = MIME::Head->read(\*RAW); $subject = $head->get('Subject:', 0); chop($subject); $subject =~ s/ /_/g; $subject =~ s#/#-#g; $subject =~ s#,##g; $subject =~ s#'##g; $subject =~ s#&##g; $subject =~ s#\(##g; $subject =~ s#\)##g; print "$subject\n"; # # when the two $entity lines are uncommented, #the code stops processing after the 1st message. # What change is required to get all the messages parsed & processed? # with the two lines immediately below #(which are now commented out and start with $entity) # All 242 subjects get printed. #$entity = $parser->parse(\*RAW) or die "parse failed\n"; #$entity->dump_skeleton; $msg_start = 1; # } } exit;
You can lead {some|many|most} to knowledge, but a few will steadfastly refuse to think (for themsleves). Clue Repellant!

In reply to MIME::Parser by solbeach

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.