.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .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. \*(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- .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" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Email::FolderType 3pm" .TH Email::FolderType 3pm "2007-03-22" "perl v5.22.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Email::FolderType \- determine the type of a mail folder .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Email::FolderType qw(folder_type); \& \& print folder_type "~/mymbox"; # prints \*(AqMbox\*(Aq \& print folder_type "~/a_maildir/"; # prints \*(AqMaildir\*(Aq \& print folder_type "some_mh/."; # prints \*(AqMH\*(Aq \& print folder_type "an_archive//"; # prints \*(AqEzmlm\*(Aq .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Provides a utility subroutine for detecting the type of a given mail folder. .SH "SUBROUTINES" .IX Header "SUBROUTINES" .SS "folder_type " .IX Subsection "folder_type " Automatically detects what type of mail folder the path refers to and returns the name of that type. .PP It primarily bases the type on the suffix of the path given. .PP .Vb 5 \& Suffix | Type \& \-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\- \& / | Maildir \& /. | MH \& // | Ezmlm .Ve .PP In case of no known suffix it checks for a known file structure. If that doesn't work out it defaults to \f(CW\*(C`Mbox\*(C'\fR although, if the \f(CW\*(C`Mbox\*(C'\fR matcher has been overridden or the default changed (see \fB\s-1DEFAULT MATCHER\s0\fR below) then it will return undef. .SS "matchers" .IX Subsection "matchers" Returns a list of all the matchers available to the system. .SH "DEFAULT MATCHER" .IX Header "DEFAULT MATCHER" Currently the default matcher is \f(CW\*(C`Mbox\*(C'\fR and therefore it is always checked last and always returns \f(CW1\fR. .PP If you really want to change this then you should override \f(CW\*(C`Email::FolderType::Mbox::match\*(C'\fR and/or change the variable \f(CW$Email::FolderType::DEFAULT\fR to be something other than \f(CW\*(AqMbox\*(Aq\fR. .PP .Vb 2 \& use Email::FolderType; \& use Email::FolderType::Mbox; \& \& $Email::FolderType::DEFAULT = \*(AqNewDefault\*(Aq; \& \& package Email::FolderType::Mbox; \& sub match { return (defined $_[0] && \-f $_[0]) } \& \& package Email::FolderType::NewDefault; \& sub match { return (defined $_[0] && $_[0] =~ m!some crazy pattern!) } \& 1; .Ve .SH "REGISTERING NEW TYPES" .IX Header "REGISTERING NEW TYPES" \&\f(CW\*(C`Email::FolderType\*(C'\fR briefly flirted with a rather clunky \f(CW\*(C`register_type\*(C'\fR method for registering new matchers but, in retrospect that wasn't a great idea. .PP Instead, in this version we've reverted to a \f(CW\*(C`Module::Pluggable\*(C'\fR based system \- any classes in the \f(CW\*(C`Email::FolderType::\*(C'\fR namespace will be interrogated to see if they have a c method. .PP If they do then it will be passed the folder name. If the folder matches then the match function should return \f(CW1\fR. For example ... .PP .Vb 1 \& package Email::FolderType::GzippedMbox; \& \& sub match { \& my $folder = shift; \& return (\-f $folder && $folder =~ /.gz$/); \& } \& \& 1; .Ve .PP These can even be defined inline ... .PP .Vb 1 \& #!perl \-w \& \& use strict; \& use Email::Folder; \& use Email::LocalDelivery; \& \& # copy all mail from an IMAP folder \& my $folder = Email::Folder\->new(\*(Aqimap://example.com\*(Aq); # read INBOX \& for ($folder\->messages) { \& Email::LocalDelivery\->deliver($_\->as_string, \*(Aqlocal_mbox\*(Aq); \& } \& \& package Email::FolderType::IMAP; \& \& sub match { \& my $folder = shift; \& return $folder =~ m!^imap://!; \& } \& \& 1; .Ve .PP If there is demand for a compatability shim for the old \f(CW\*(C`register_type\*(C'\fR method then we can implement one. Really though, this is much better in the long run. .SH "PERL EMAIL PROJECT" .IX Header "PERL EMAIL PROJECT" This module is maintained by the Perl Email Project. .PP .Vb 1 \& http://emailproject.perl.org/wiki/Email::FolderType .Ve .SH "AUTHOR" .IX Header "AUTHOR" Simon Wistow .SH "COPYING" .IX Header "COPYING" (C) Copyright 2005, Simon Wistow .PP Distributed under the same terms as Perl itself. .PP This software is under no warranty and will probably ruin your life, kill your friends, burn your house and bring about the apocalypse. .SH "SEE ALSO" .IX Header "SEE ALSO" Email::LocalDelivery, Email::Folder