Mail::Box::Tie::HASH(3pm) | User Contributed Perl Documentation | Mail::Box::Tie::HASH(3pm) |
Mail::Box::Tie::HASH - access an existing message folder as a hash
tie my(%inbox), 'Mail::Box::Tie::HASH', $folder; foreach my $msgid (keys %inbox) { print $inbox{$msgid}; delete $inbox{$msgid}; } $inbox{$msg->messageId} = $msg;
Certainly when you look at a folder as being a set of related messages based on message-id, it is logical to access the folder through a hash.
For a tied hash, the message-id is used as the key. The message-id is usually unique, but 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.
This implementation uses basic folder access routines which are related to the message-id.
example:
my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open(access => 'rw'); tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
example:
%inbox = (); %inbox = ($msg->messageId, $msg); #before adding msg
example:
delete $inbox{$msgid};
example:
if(exists $inbox{$msgid}) ...
example:
my $msg = $inbox{$msgid}; if($inbox{$msgid}->isDummy) ...
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; }
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;
This module is part of Mail-Box distribution version 3.009, built on August 18, 2020. Website: http://perl.overmeer.net/CPAN/
Copyrights 2001-2020 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
2020-08-20 | perl v5.30.3 |