Email:...derType(3pm)
β¨ NAME β¨
okay so this is Email::FolderType, from the Perl user-contributed docs (Email::FolderType(3pm)) β it determines the type of a mail folder. that's it. that's the whole job. she's a specialist π
πΈ VERSION πΈ
version 0.814 β we're on the modern timeline bestie β¨
π¦ SYNOPSIS π¦
use Email::FolderType qw(folder_type);
print folder_type "~/mymbox"; # prints 'Mbox'
print folder_type "~/a_maildir/"; # prints 'Maildir'
print folder_type "some_mh/."; # prints 'MH'
print folder_type "an_archive//"; # prints 'Ezmlm'
look at her go. four different folders, four instant answers, no drama π
π DESCRIPTION π
she gives you a little utility subroutine that sniffs out what type of mail folder a given folder is. detection era. that's literally the vibe β you hand her a path, she tells you what she is π
π SUBROUTINES π
β folder_type <path> β
she auto-detects what type of mail folder your path is pointing at, and hands you back the name of that type. main character behaviour fr fr.
the way she does it: she's mostly clocking the suffix of the path you gave her.
/βMaildir/.βMH//βEzmlm
and if the suffix is giving nothing? then she checks for a known file structure. and if that doesn't work out either, she defaults to Mbox β BUT listen, this is important: if the Mbox matcher has been overridden, or the default has been changed (peep DEFAULT MATCHER down below π), then she'll return undef instead. so don't be out here assuming, okay?
π§ matchers π§
returns a list of all the matchers available to the system. the whole roster. the full squad π«Ά
π DEFAULT MATCHER π
currently the default matcher is Mbox, which means she is always checked last and always returns 1. she's the safety net. the fallback bestie.
so if you really wanna change that, you'd override Email::FolderType::Mbox::match and/or change the variable $Email::FolderType::DEFAULT to be something other than 'Mbox'. like this:
use Email::FolderType;
use Email::FolderType::Mbox;
$Email::FolderType::DEFAULT = 'NewDefault';
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;
that's the whole recipe. go off π
π REGISTERING NEW TYPES π
okay so tea time β Email::FolderType briefly flirted with a rather clunky register_type method for registering new matchers β and in retrospect? that wasn't a great idea. we said what we said π
instead, in this version, we've reverted to a Module::Pluggable based system β meaning any classes sitting in the Email::FolderType:: namespace get interrogated to see if they have a c<match> method.
if they do, then she passes them the folder name. if the folder matches, the match function should return 1. for example...
package Email::FolderType::GzippedMbox;
sub match {
my $folder = shift;
return (-f $folder && $folder =~ /.gz$/);
}
1;
and honestly? these can even be defined inline β¨ like so:
#!perl -w
use strict;
use Email::Folder;
use Email::LocalDelivery;
# copy all mail from an IMAP folder
my $folder = Email::Folder->new('imap://example.com'); # read INBOX
for ($folder->messages) {
Email::LocalDelivery->deliver($_->as_string, 'local_mbox');
}
package Email::FolderType::IMAP;
sub match {
my $folder = shift;
return $folder =~ m!^imap://!;
}
1;
so like β if there's demand for a compatability shim for the old register_type method, then sure, we can implement one. but really though? this is much better in the long run. trust π
π AUTHOR π
Simon Wistow <simon@thegestalt.org> β icon, legend, the moment π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2005 by Simon Wistow.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay, legally speaking π«Ά
and that's the page bestie!! π sign-off time: this was perl v5.36.0, dated 2023-07-19, and it lives under Email:...derType(3pm). no cap, go detect some folders π
β¨
π¦ where this page comes from
- debian trixie: libemail-foldertype-perl 0.814-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libemail-foldertype-perl 0.814-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libemail-foldertype-perl 0.814-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libemail-foldertype-perl 0.814-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms