View on
Casey West > Data-Message-1.01 > Data::Message



Annotate this POD


Open  0
View/Report Bugs
Module Version: 1.01   Source   Latest Release: Data-Message-1.104


Data::Message - Parse and Reconstruct RFC2822 Compliant Messages


  use Data::Message;
  my $message = Data::Message->new(join('',<>), fold => 1);
  print $message->header("Customer-ID");
  print $message->body;


This module is a generic interface to dealing with RFC2822 compliant messages. Email is the most common example of messages in this format, but not the only one. HTTP requests and responses are also sent and received in this format. Many other systems rely on storing or sending information with a header of key/value pairs followed by an optional body.

Because Email::Simple is so good at parsing this format, and so fast, this module inherits from it. Changes to the interface are only prevelant in options provided to the constructor new(). For any other interface usage documentation, please see Email::Simple.

Because Data::Message is a subclass of Email::Simple, its mixins will work with this package. For example, you may use Email::Simple::Creator to aid in the creation of Data::Message objects from scratch.


  my $message = Data::Message->new(join( '', <> ),
                                   fold    => 1,
                                   grouchy => 1);

The first argument is a scalar value containing the text of the payload to be parsed. Subsequent arguments are passed as key/value pairs.

fold, which is false by default, will tell Data::Message if it should fold headers. If given a true value, headers longer than 78 characters will be folded.

grouchy, which is false by default, will instruct Data::Message to complain loudly if non-ascii characters are used as header names, when setting headers via header_set(). If grouchy is true, calls to header_set() should be wrapped in eval as they may die.


Email::Simple, Email::Simple::Creator, Email::Simple::Headers, perl.


Casey West, <>.


  Copyright (c) 2004 Casey West.  All rights reserved.
  This module is free software; you can redistribute it and/or modify it
  under the same terms as Perl itself.
syntax highlighting: