1Mail::Box::Tie::HASH(3)User Contributed Perl DocumentatioMnail::Box::Tie::HASH(3)
2
3
4

NAME

6       Mail::Box::Tie::HASH - access an existing message folder as a hash
7

SYNOPSIS

9        tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
10
11        foreach my $msgid (keys %inbox)
12        {   print $inbox{$msgid};
13            delete $inbox{$msgid};
14        }
15
16        $inbox{$msg->messageId} = $msg;
17

DESCRIPTION

19       Certainly when you look at a folder as being a set of related messages
20       based on message-id, it is logical to access the folder through a hash.
21
22       For a tied hash, the message-id is used as the key.  The message-id is
23       usually unique, but when two or more instances of the same message are
24       in the same folder, one will be flagged for deletion and the other will
25       be returned.
26
27       This implementation uses basic folder access routines which are related
28       to the message-id.
29

METHODS

31   Constructors
32       TIEHASH('Mail::Box::Tie::HASH', FOLDER)
33           Connects the FOLDER object to a HASH.
34
35           example:
36
37            my $mgr    = Mail::Box::Manager->new;
38            my $folder = $mgr->open(access => 'rw');
39            tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
40
41   Tied Interface
42       $obj->CLEAR()
43           Remove the contents of the hash.  This is not really possible, but
44           all the messages will be flagged for deletion.
45
46           example:
47
48            %inbox = ();
49            %inbox = ($msg->messageId, $msg); #before adding msg
50
51       $obj->DELETE($message_id)
52           Remove the message with the specified $message_id.
53
54           example:
55
56            delete $inbox{$msgid};
57
58       $obj->EXISTS($message_id)
59           Check whether a message with a certain $message_id exists.
60
61           example:
62
63            if(exists $inbox{$msgid}) ...
64
65       $obj->FETCH($message_id)
66           Get the message with the specified id.  The returned message may be
67           a dummy if message thread detection is used.  Returns "undef" when
68           there is no message with the specified id.
69
70           example:
71
72            my $msg = $inbox{$msgid};
73            if($inbox{$msgid}->isDummy)  ...
74
75       $obj->FIRSTKEY()
76           See NEXTKEY().
77
78       $obj->NEXTKEY($previous)
79           FIRSTKEY() returns the first message-id/message pair from the
80           folder, and NEXTKEY returns the message-id/message pair for the
81           next message, in the order in which the message is stored in the
82           folder.
83
84           Messages flagged for deletion will not be returned. See the
85           Mail::Box::messages() method of the folder type for more
86           information about the folder message order.
87
88           example:
89
90            foreach my $msgid (keys %inbox) ...
91            foreach my $msg (values %inbox) ...
92
93            while(my ($msgid, $msg) = each %inbox) {
94               $msg->print unless $msg->isDeleted;
95            }
96
97       $obj->STORE(undef, $message)
98           Store a message in the folder.  The key must be "undef", because
99           the message-id of the specified message is taken.  This is shown in
100           the first example.  However, as you see, it is a bit complicated to
101           specify "undef", therefore the string "undef" is accepted as well.
102
103           The message may be converted into something which can be stored in
104           the folder type which is at stake.  The added instance is returned.
105
106           example:
107
108            $inbox{ (undef) } = $msg;
109            $inbox{undef} = $msg;
110

SEE ALSO

112       This module is part of Mail-Box distribution version 3.008, built on
113       October 04, 2019. Website: http://perl.overmeer.net/CPAN/
114

LICENSE

116       Copyrights 2001-2019 by [Mark Overmeer]. For other contributors see
117       ChangeLog.
118
119       This program is free software; you can redistribute it and/or modify it
120       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
121
122
123
124perl v5.30.1                      2020-01-30           Mail::Box::Tie::HASH(3)
Impressum