.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mail::Header 3" .TH Mail::Header 3 "2007-05-11" "perl v5.8.8" "User Contributed Perl Documentation" .SH "NAME" Mail::Header \- manipulate mail RFC822 compliant headers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mail::Header; .Ve .PP .Vb 3 \& $head = new Mail::Header; \& $head = new Mail::Header \e*STDIN; \& $head = new Mail::Header [<>], Modify => 0; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This package provides a class object which can be used for reading, creating, manipulating and writing \s-1RFC822\s0 compliant headers. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .IP "new ( [ \s-1ARG\s0 ], [ \s-1OPTIONS\s0 ] )" 4 .IX Item "new ( [ ARG ], [ OPTIONS ] )" \&\f(CW\*(C`ARG\*(C'\fR may be either a file descriptor (reference to a \s-1GLOB\s0) or a reference to an array. If given the new object will be initialized with headers either from the array of read from the file descriptor. .Sp \&\f(CW\*(C`OPTIONS\*(C'\fR is a list of options given in the form of key-value pairs, just like a hash table. Valid options are .RS 4 .IP "\fBModify\fR" 8 .IX Item "Modify" If this value is \fItrue\fR then the headers will be re\-formatted, otherwise the format of the header lines will remain unchanged. .IP "\fBMailFrom\fR" 8 .IX Item "MailFrom" This option specifies what to do when a header in the form `From ' is encountered. Valid values are \f(CW\*(C`IGNORE\*(C'\fR \- ignore and discard the header, \&\f(CW\*(C`ERROR\*(C'\fR \- invoke an error (call die), \f(CW\*(C`COERCE\*(C'\fR \- rename them as Mail-From and \f(CW\*(C`KEEP\*(C'\fR \- keep them. .IP "\fBFoldLength\fR" 8 .IX Item "FoldLength" The default length of line to be used when folding header lines .RE .RS 4 .RE .SH "METHODS" .IX Header "METHODS" .IP "modify ( [ \s-1VALUE\s0 ] )" 4 .IX Item "modify ( [ VALUE ] )" If \f(CW\*(C`VALUE\*(C'\fR is \fIfalse\fR then \f(CW\*(C`Mail::Header\*(C'\fR will not do any automatic reformatting of the headers, other than to ensure that the line starts with the tags given. .IP "mail_from ( \s-1OPTION\s0 )" 4 .IX Item "mail_from ( OPTION )" \&\f(CW\*(C`OPTION\*(C'\fR specifies what to do when a \f(CW`From '\fR line is encountered. Valid values are \f(CW\*(C`IGNORE\*(C'\fR \- ignore and discard the header, \&\f(CW\*(C`ERROR\*(C'\fR \- invoke an error (call die), \f(CW\*(C`COERCE\*(C'\fR \- rename them as Mail-From and \f(CW\*(C`KEEP\*(C'\fR \- keep them. .IP "fold ( [ \s-1LENGTH\s0 ] )" 4 .IX Item "fold ( [ LENGTH ] )" Fold the header. If \f(CW\*(C`LENGTH\*(C'\fR is not given then \f(CW\*(C`Mail::Header\*(C'\fR uses the following rules to determine what length to fold a line. .Sp The fold length for the tag that is begin processed .Sp The default fold length for the tag that is being processed .Sp The default fold length for the object .IP "extract ( \s-1ARRAY_REF\s0 )" 4 .IX Item "extract ( ARRAY_REF )" Extract a header from the given array. \f(CW\*(C`extract\*(C'\fR \fBwill modify\fR this array. Returns the object that the method was called on. .IP "read ( \s-1FD\s0 )" 4 .IX Item "read ( FD )" Read a header from the given file descriptor. .IP "empty ()" 4 .IX Item "empty ()" Empty the \f(CW\*(C`Mail::Header\*(C'\fR object of all lines. .IP "header ( [ \s-1ARRAY_REF\s0 ] )" 4 .IX Item "header ( [ ARRAY_REF ] )" \&\f(CW\*(C`header\*(C'\fR does multiple operations. First it will extract a header from the array, if given. It will the reformat the header, if reformatting is permitted, and finally return a reference to an array which contains the header in a printable form. .IP "header_hashref ( [ \s-1HASH_REF\s0 ] )" 4 .IX Item "header_hashref ( [ HASH_REF ] )" As \f(CW\*(C`header\*(C'\fR, but it will eventually set headers from a hash reference, and it will return the headers as a hash reference. .Sp The values in the hash might either be a scalar or an array reference, as an example: .Sp .Vb 2 \& $hashref->{From}='Tobias Brox '; \& $hashref->{To}=['you@somewhere', 'me@localhost']; .Ve .IP "add ( \s-1TAG\s0, \s-1LINE\s0 [, \s-1INDEX\s0 ] )" 4 .IX Item "add ( TAG, LINE [, INDEX ] )" Add a new line to the header. If \f(CW\*(C`TAG\*(C'\fR is \fIundef\fR the the tag will be extracted from the beginning of the given line. If \f(CW\*(C`INDEX\*(C'\fR is given the new line will be inserted into the header at the given point, otherwise the new line will be appended to the end of the header. .IP "replace ( \s-1TAG\s0, \s-1LINE\s0 [, \s-1INDEX\s0 ] )" 4 .IX Item "replace ( TAG, LINE [, INDEX ] )" Replace a line in the header. If \f(CW\*(C`TAG\*(C'\fR is \fIundef\fR the the tag will be extracted from the beginning of the given line. If \f(CW\*(C`INDEX\*(C'\fR is given the new line will replace the Nth instance of that tag, otherwise the first instance of the tag is replaced. If the tag does not appear in the header then a new line will be appended to the header. .IP "combine ( \s-1TAG\s0 [, \s-1WITH\s0 ] )" 4 .IX Item "combine ( TAG [, WITH ] )" Combine all instances of \f(CW\*(C`TAG\*(C'\fR into one. The lines will be joined togther with \f(CW\*(C`WITH\*(C'\fR, or a single space if not given. The new item will be positioned in the header where the first instance was, all other instances of <\s-1TAG\s0> will be removed. .IP "get ( \s-1TAG\s0 [, \s-1INDEX\s0 ] )" 4 .IX Item "get ( TAG [, INDEX ] )" Get the text from a line. If \f(CW\*(C`INDEX\*(C'\fR is given then the text of the Nth instance will be returned. If it is not given the return value depends on the context in which \f(CW\*(C`get\*(C'\fR was called. In an array context a list of all the text from all the instances of \f(CW\*(C`TAG\*(C'\fR will be returned. In a scalar context the text for the first instance will be returned. .Sp The lines are unfolded, but still terminated with a new-line (see \f(CW\*(C`chomp\*(C'\fR) .IP "delete ( \s-1TAG\s0 [, \s-1INDEX\s0 ] )" 4 .IX Item "delete ( TAG [, INDEX ] )" Delete a tag from the header. If \f(CW\*(C`INDEX\*(C'\fR id given then the Nth instance of the tag will be removed. If \f(CW\*(C`INDEX\*(C'\fR is not given all instances of tag will be removed. .IP "count ( \s-1TAG\s0 )" 4 .IX Item "count ( TAG )" Returns the number of times the given atg appears in the header .IP "print ( [ \s-1FD\s0 ] )" 4 .IX Item "print ( [ FD ] )" Print the header to the given file descriptor, or \f(CW\*(C`STDOUT\*(C'\fR if no file descriptor is given. .IP "as_string ()" 4 .IX Item "as_string ()" Returns the header as a single string. .IP "fold_length ( [ \s-1TAG\s0 ], [ \s-1LENGTH\s0 ] )" 4 .IX Item "fold_length ( [ TAG ], [ LENGTH ] )" Set the default fold length for all tags or just one. With no arguments the default fold length is returned. With two arguments it sets the fold length for the given tag and returns the previous value. If only \f(CW\*(C`LENGTH\*(C'\fR is given it sets the default fold length for the current object. .Sp In the two argument form \f(CW\*(C`fold_length\*(C'\fR may be called as a static method, setting default fold lengths for tags that will be used by \fBall\fR \&\f(CW\*(C`Mail::Header\*(C'\fR objects. See the \f(CW\*(C`fold\*(C'\fR method for a description on how \f(CW\*(C`Mail::Header\*(C'\fR uses these values. .IP "tags ()" 4 .IX Item "tags ()" Retruns an array of all the tags that exist in the header. Each tag will only appear in the list once. The order of the tags is not specified. .IP "dup ()" 4 .IX Item "dup ()" Create a duplicate of the current object. .IP "cleanup ()" 4 .IX Item "cleanup ()" Remove any header line that, other than the tag, only contains whitespace .IP "unfold ( [ \s-1TAG\s0 ] )" 4 .IX Item "unfold ( [ TAG ] )" Unfold all instances of the given tag so that they do not spread across multiple lines. \s-1IF\s0 \f(CW\*(C`TAG\*(C'\fR is not given then all lines are unfolded. .Sp The unfolding process is wrong but (for compatibility reasons) will not be repaired: only one blank at the start of the line should be removed, not all of them. .SH "AUTHOR" .IX Header "AUTHOR" Graham Barr. Maintained by Mark Overmeer .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2002\-2003 Mark Overmeer, 1995\-2001 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.