Mail::...::HASH(3pm)
π NAME π
okay bestie, meet Mail::Box::Tie::HASH β it lets you access an existing message folder as a hash. like, a whole folder, but you poke at it with %hash syntax. iconic behavior fr fr π
(the manual page is filed under Mail::...::HASH(3pm) if you're out here hunting for it, mwah π
)
π INHERITANCE π
Mail::Box::Tie::HASH
is a Mail::Box::Tie
so it's a child of Mail::Box::Tie, it inherited the family lewks, no cap.
β¨ SYNOPSIS β¨
tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
foreach my $msgid (keys %inbox)
{ print $inbox{$msgid};
delete $inbox{$msgid};
}
$inbox{$msg->messageId} = $msg;
like literally three moves and you've got a whole mailbox as a hash. the way that just works π¦
π DESCRIPTION π
ngl, when you look at a folder as being a set of related messages based on message-id, it is so logical to access the folder through a hash. big brain move, we're obsessed π
for a tied hash, the message-id is used as the key. the message-id is usually unique, BUT β and this is the tea β when two or more instances of the same message are in the same folder, one will be flagged for deletion and the other will be returned. so like, one of them has to go, sorry babe π
this implementation uses basic folder access routines which are related to the message-id. (lowkey that's the whole vibe.)
Extends "DESCRIPTION" in Mail::Box::Tie.
πΈ METHODS πΈ
Extends "METHODS" in Mail::Box::Tie.
π§ Constructors π§
Extends "Constructors" in Mail::Box::Tie.
tie %hash, 'Mail::Box::Tie::HASH', FOLDERβ connects theFOLDERobject to aHASH. it's giving matchmaker, except both of them are the same thing. π₯
Β» example:
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(access => 'rw');
tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
$class->new($folder, $type)β inherited, see "Constructors" inMail::Box::Tie. (not her moment, she's on loan from the parent class, periodt.)
β Attributes β
Extends "Attributes" in Mail::Box::Tie.
$obj->folder()β inherited, see "Attributes" inMail::Box::Tie.$obj->type()β inherited, see "Attributes" inMail::Box::Tie.
π Tied Interface π
$obj->CLEAR()β remove the contents of the hash. bestie, this is not really possible, but all the messages will be flagged for deletion. so it's giving "cleared" but it's actually just "marked, we'll deal with it later" π
Β» example:
%inbox = ();
%inbox = ($msg->messageId, $msg); #before adding msg
$obj->DELETE($message_id)β remove the message with the specified$message_id. bye boo π
Β» example:
delete $inbox{$msgid};
$obj->EXISTS($message_id)β check whether a message with a certain$message_idexists. vibe check: does it exist or not β¨
Β» example:
if(exists $inbox{$msgid}) ...
$obj->FETCH($message_id)β get the message with the specified id. heads up: the returned message may be a dummy if message thread detection is used. and it returnsundefwhen there is no message with the specified id. no message, no service π
Β» example:
my $msg = $inbox{$msgid};
if($inbox{$msgid}->isDummy) ...
$obj->FIRSTKEY()β seeNEXTKEY(). (she's the opening act, NEXTKEY is the main character.)$obj->NEXTKEY($previous)βFIRSTKEY()returns the first message-id/message pair from the folder, andNEXTKEYreturns the message-id/message pair for the next message, in the order in which the message is stored in the folder.
messages flagged for deletion will not be returned. see the Mail::Box::messages() method of the folder type for more information about the folder message order. π
Β» example:
foreach my $msgid (keys %inbox) ...
foreach my $msg (values %inbox) ...
while(my ($msgid, $msg) = each %inbox) {
$msg->print unless $msg->isDeleted;
}
$obj->STORE(undef, $message)β store a message in the folder. the key must beundef, because the message-id of the specified message is taken. this is shown in the first example. however, as you see, it is a bit complicated to specifyundef, therefore the string"undef"is accepted as well. two ways to say nothing, slay π«Ά
the message may be converted into something which can be stored in the folder type which is at stake. the added instance is returned. π₯
Β» example:
$inbox{ (undef) } = $msg;
$inbox{undef} = $msg;
π DIAGNOSTICS π
- Error: no folder specified to tie to. β cast by
new(). babe you forgot the folder, the whole thing cannot function without a folder π - Warning: use undef as key, because the message-id of the message is used. β cast by
STORE(). just useundef, bestie, she's asking nicely π
π₯ SEE ALSO π₯
this module is part of Mail-Box version 4.02, built on April 10, 2026. β¨
Website: http://perl.overmeer.net/CPAN/
π LICENSE π
for contributors see file ChangeLog. (iykyk π)
this software is copyright (c) 2001-2026 by Mark Overmeer.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt π
and that's the whole page, bestie π β signed off from perl v5.40.1, dated 2026-05-09, filed as Mail::...::HASH(3pm). go forth and tie responsibly π β¨
π¦ where this page comes from
- ubuntu stonking: libmail-box-perl 4.02-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