MIME::Parser

MIME::Parser is a experimental class for parsing MIME streams.
Download

MIME::Parser Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Eryq, ZeeGee Software Inc and David F. Skoll
  • Publisher web site:
  • http://search.cpan.org/~dskoll/MIME-tools-5.420/lib/MIME/Head.pm

MIME::Parser Tags


MIME::Parser Description

MIME::Parser is a experimental class for parsing MIME streams. MIME::Parser is a experimental class for parsing MIME streams.SYNOPSISBefore reading further, you should see MIME::Tools to make sure that you understand where this module fits into the grand scheme of things. Go on, do it now. I'll wait.Ready? Ok...Basic usage examples ### Create a new parser object: my $parser = new MIME::Parser; ### Tell it where to put things: $parser->output_under("/tmp"); ### Parse an input filehandle: $entity = $parser->parse(*STDIN); ### Congratulations: you now have a (possibly multipart) MIME entity! $entity->dump_skeleton; # for debuggingExamples of input ### Parse from filehandles: $entity = $parser->parse(*STDIN); $entity = $parser->parse(IO::File->new("some command|"); ### Parse from any object that supports getline() and read(): $entity = $parser->parse($myHandle); ### Parse an in-core MIME message: $entity = $parser->parse_data($message); ### Parse an MIME message in a file: $entity = $parser->parse_open("/some/file.msg"); ### Parse an MIME message out of a pipeline: $entity = $parser->parse_open("gunzip - < file.msg.gz |"); ### Parse already-split input (as "deliver" would give it to you): $entity = $parser->parse_two("msg.head", "msg.body");Examples of output control ### Keep parsed message bodies in core (default outputs to disk): $parser->output_to_core(1); ### Output each message body to a one-per-message directory: $parser->output_under("/tmp"); ### Output each message body to the same directory: $parser->output_dir("/tmp"); ### Change how nameless message-component files are named: $parser->output_prefix("msg");Examples of error recovery ### Normal mechanism: eval { $entity = $parser->parse(*STDIN) }; if ($@) { $results = $parser->results; $decapitated = $parser->last_head; ### get last top-level head } ### Ultra-tolerant mechanism: $parser->ignore_errors(1); $entity = eval { $parser->parse(*STDIN) }; $error = ($@ || $parser->last_error); ### Cleanup all files created by the parse: eval { $entity = $parser->parse(*STDIN) }; ... $parser->filer->purge;Examples of parser options ### Automatically attempt to RFC-1522-decode the MIME headers? $parser->decode_headers(1); ### default is false ### Parse contained "message/rfc822" objects as nested MIME streams? $parser->extract_nested_messages(0); ### default is true ### Look for uuencode in "text" messages, and extract it? $parser->extract_uuencode(1); ### default is false ### Should we forgive normally-fatal errors? $parser->ignore_errors(0); ### default is trueMiscellaneous examples ### Convert a Mail::Internet object to a MIME::Entity: @lines = (@{$mail->header}, "n", @{$mail->body}); $entity = $parser->parse_data(@lines); Requirements: · Perl


MIME::Parser Related Software