#!/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;
In reply to MIME::Parser by solbeach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |