/[suikacvs]/messaging/manakai/lib/Message/Field/Unstructured.pm
Suika

Contents of /messaging/manakai/lib/Message/Field/Unstructured.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Sat Mar 16 01:26:31 2002 UTC (22 years, 8 months ago) by wakaba
Branch: MAIN
2002-03-15  wakaba <w@suika.fam.cx>

	* Date.pm: New module.

1 wakaba 1.1
2     =head1 NAME
3    
4     Message::Field::Address Perl module
5    
6     =head1 DESCRIPTION
7    
8     Perl module for RFC 822/2822 address related C<field>s.
9     $Id: $
10    
11     =cut
12    
13     package Message::Field::Unstructured;
14     require 5.6.0;
15     use strict;
16     use re 'eval';
17     use vars qw(%REG $VERSION);
18     $VERSION = '1.00';
19    
20     use overload '""' => sub {shift->stringify};
21    
22     =head2 Message::Field::Address->new ()
23    
24     Return empty address object.
25    
26     =cut
27    
28     sub new ($) {
29     bless {}, shift;
30     }
31    
32     =head2 Message::Field::Address->parse ($unfolded_field_body)
33    
34     Parse structured C<field-body> contain of C<address-list>.
35    
36     =cut
37    
38     sub parse ($$) {
39     my $self = bless {}, shift;
40     my $field_body = shift;
41     $self->{field_body} = $field_body;
42     $self;
43     }
44    
45     sub stringify ($) {
46     my $self = shift;
47     $self->{field_body};
48     }
49    
50     sub as_plain_string ($) {
51     my $self = shift;
52     $self->{field_body};
53     }
54    
55     =head1 EXAMPLE
56    
57     ## Compose field-body for To: field.
58    
59     use Message::Field::Address;
60     my $addr = new Message::Field::Address;
61     $addr->add ('foo@example.org', name => 'Mr. foo bar');
62     $addr->add ('webmaster@example.org', group => 'administrators');
63     $addr->add ('postmaster@example.org', group => 'administrators');
64    
65     my $field_body = $addr->stringify ();
66    
67    
68     ## Output parsed address-list tree.
69    
70     use Message::Field::Address;
71     my $addr = Message::Field::Address->parse ($field_body);
72    
73     for my $i (@$addr) {
74     if ($i->{type} eq 'group') {
75     print "\x40 $i->{display_name}: \n";
76     for my $j (@{$i->{address}}) {
77     print "\t- $j->{display_name} <$j->{route}$j->{addr_spec}>\n";
78     }
79     } else {
80     print "- $i->{display_name} <$i->{route}$i->{addr_spec}>\n";
81     }
82     }
83    
84     =head1 LICENSE
85    
86     Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
87    
88     This program is free software; you can redistribute it and/or modify
89     it under the terms of the GNU General Public License as published by
90     the Free Software Foundation; either version 2 of the License, or
91     (at your option) any later version.
92    
93     This program is distributed in the hope that it will be useful,
94     but WITHOUT ANY WARRANTY; without even the implied warranty of
95     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96     GNU General Public License for more details.
97    
98     You should have received a copy of the GNU General Public License
99     along with this program; see the file COPYING. If not, write to
100     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
101     Boston, MA 02111-1307, USA.
102    
103     =head1 CHANGE
104    
105     See F<ChangeLog>.
106    
107     =cut
108    
109     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24