=head1 NAME Message::Body::TextPlain Perl module =head1 DESCRIPTION Perl module for text/plain media type. =cut package Message::Body::TextPlain; use strict; use vars qw($VERSION %DEFAULT); $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; require Message::Header; use overload '""' => sub {shift->stringify}; =head2 Message::Body::TextPlain->new ([%option]) Returns new Message::Body::TextPlain instance. Some options can be specified as hash. =cut sub new ($;%) { my $class = shift; my $self = bless {option => {@_}}, $class; for (keys %DEFAULT) {$self->{option}->{$_} ||= $DEFAULT{$_}} $self; } =head2 Message::Body::TextPlain->parse ($body, [%option]) Returns a new Message::Body::TextPlain with given body object. Some options can be specified as hash. =cut sub parse ($$;%) { my $class = shift; my $body = shift; my $self = bless {option => {@_}}, $class; for (keys %DEFAULT) {$self->{option}->{$_} ||= $DEFAULT{$_}} $self->header ($self->{option}->{header}); $self->{body} = $body; $self; } =head2 $self->header ([$new_header]) =cut sub header ($;$) { my $self = shift; my $new_header = shift; if (ref $new_header) { $self->{header} = $new_header; } elsif ($new_header) { $self->{header} = Message::Header->parse ($new_header); } unless ($self->{header}) { $self->{header} = new Message::Header; } $self->{header}; } =head2 $self->body ([$new_body]) Returns C
as string unless $new_body. Set $new_body instead of current C. =cut sub body ($;$) { my $self = shift; my $new_body = shift; if ($new_body) { $self->{body} = $new_body; } $self->{body}; } =head2 $self->stringify ([%option]) Returns the C as a string. =cut sub stringify ($;%) { my $self = shift; my %OPT = @_; my ($body) = (scalar $self->{body}); $body .= "\n" unless $body =~ /\n$/; $body; } sub as_string ($;%) {shift->stringify (@_)} =head2 $self->option ($option_name) Returns/set (new) value of the option. =cut sub option ($$;$) { my $self = shift; my ($name, $newval) = @_; if ($newval) { $self->{option}->{$name} = $newval; } $self->{option}->{$name}; } =head1 SEE ALSO RFC 822