1Mail::Field(3) User Contributed Perl Documentation Mail::Field(3)
2
3
4
6 Mail::Field - Base class for manipulation of mail header fields
7
9 Mail::Field is extended by
10 Mail::Field::AddrList
11 Mail::Field::Date
12 Mail::Field::Generic
13
15 use Mail::Field;
16
17 my $field = Mail::Field->new('Subject', 'some subject text');
18 my $field = Mail::Field->new(Subject => 'some subject text');
19 print $field->tag,": ",$field->stringify,"\n";
20
21 my $field = Mail::Field->subject('some subject text');
22
24 "Mail::Field" creates and manipulates fields in MIME headers, collected
25 within a Mail::Header object. Different field types have their own
26 sub-class (extension), defining additional useful accessors to the
27 field content.
28
29 People are invited to merge their implementation to special fields into
30 MailTools, to maintain a consistent set of packages and documentation.
31
33 Constructors
34 Mail::Field (and it's sub-classes) define several methods which return
35 new objects. These can all be categorized as constructor.
36
37 Mail::Field->combine(FIELDS)
38
39 Take a LIST of "Mail::Field" objects (which should all be of the
40 same sub-class) and create a new object in that same class.
41
42 Mail::Field->extract(TAG, HEAD [, INDEX ])
43
44 Takes as arguments the tag name, a "Mail::Head" object and
45 optionally an index.
46
47 If the index argument is given then "extract" will retrieve the
48 given tag from the "Mail::Head" object and create a new
49 "Mail::Field" based object. undef will be returned in the field
50 does not exist.
51
52 If the index argument is not given the the result depends on the
53 context in which "extract" is called. If called in a scalar context
54 the result will be as if "extract" was called with an index value
55 of zero. If called in an array context then all tags will be
56 retrieved and a list of "Mail::Field" objects will be returned.
57
58 Mail::Field->new(TAG [, STRING | OPTIONS])
59
60 Create an object in the class which defines the field specified by
61 the TAG argument.
62
63 "Fake" constructors
64 $obj->create(OPTIONS)
65
66 This constructor is used internally with preprocessed field
67 information. When called on an existing object, its original
68 content will get replaced.
69
70 $obj->parse
71
72 Parse a field line.
73
74 Accessors
75 $obj->set(OPTIONS)
76
77 Change the settings (the content, but then smart) of this field.
78
79 $obj->stringify
80
81 Returns the field as a string.
82
83 $obj->tag
84
85 Mail::Field->tag
86
87 Return the tag (in the correct case) for this item. Well, actually
88 any casing is OK, because the field tags are treated case-
89 insentitive; however people have some preferences.
90
91 Smart accessors
92 $obj->text([STRING])
93
94 Without arguments, the field is returned as stringify() does.
95 Otherwise, the STRING is parsed with parse() to replace the
96 object's content.
97
98 It is more clear to call either stringify() or parse() directly,
99 because this method does not add additional processing.
100
102 SUB-CLASS PACKAGE NAMES
103 All sub-classes should be called Mail::Field::name where name is
104 derived from the tag using these rules.
105
106 · Consider a tag as being made up of elements separated by '-'
107
108 · Convert all characters to lowercase except the first in each
109 element, which should be uppercase.
110
111 · name is then created from these elements by using the first N
112 characters from each element.
113
114 · N is calculated by using the formula :-
115
116 int((7 + #elements) / #elements)
117
118 · name is then limited to a maximum of 8 characters, keeping the
119 first 8 characters.
120
121 For an example of this take a look at the definition of the
122 "_header_pkg_name()" subroutine in "Mail::Field"
123
125 Error: Undefined subroutine <method> called
126
127 Mail::Field objects use autoloading to compile new functionality.
128 Apparently, the mehod called is not implemented for the specific
129 class of the field object.
130
132 This module is part of the MailTools distribution,
133 http://perl.overmeer.net/mailtools/.
134
136 The MailTools bundle was developed by Graham Barr. Later, Mark
137 Overmeer took over maintenance without commitment to further
138 development.
139
140 Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by
141 Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce
142 <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog.
143
145 Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark
146 Overmeer <perl@overmeer.net>.
147
148 This program is free software; you can redistribute it and/or modify it
149 under the same terms as Perl itself. See
150 http://www.perl.com/perl/misc/Artistic.html
151
152
153
154perl v5.12.2 2010-10-01 Mail::Field(3)