1Mail::Box::Tie::HASH(3)User Contributed Perl DocumentatioMnail::Box::Tie::HASH(3)
2
3
4
6 Mail::Box::Tie::HASH - access an existing message folder as a hash
7
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
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
31 Constructors
32
33 TIEHASH('Mail::Box::Tie::HASH', FOLDER)
34
35 Connects the FOLDER object to a HASH.
36
37 Example:
38
39 my $mgr = Mail::Box::Manager->new;
40 my $folder = $mgr->open(access => 'rw');
41 tie my(%inbox), 'Mail::Box::Tie::HASH', $folder;
42
43 Tied Interface
44
45 $obj->CLEAR
46
47 Remove the contents of the hash. This is not really possible, but
48 all the messages will be flagged for deletion.
49
50 Example:
51
52 %inbox = ();
53 %inbox = ($msg->messageId, $msg); #before adding msg
54
55 $obj->DELETE(MESSAGE-ID)
56
57 Remove the message with the specified MESSAGE-ID.
58
59 Example:
60
61 delete $inbox{$msgid};
62
63 $obj->EXISTS(MESSAGE-ID)
64
65 Check whether a message with a certain MESSAGE-ID exists.
66
67 Example:
68
69 if(exists $inbox{$msgid}) ...
70
71 $obj->FETCH(MESSAGEID)
72
73 Get the message with the specified id. The returned message may be
74 a dummy if message thread detection is used. Returns "undef" when
75 there is no message with the specified id.
76
77 Example:
78
79 my $msg = $inbox{$msgid};
80 if($inbox{$msgid}->isDummy) ...
81
82 $obj->FIRSTKEY
83
84 See NEXTKEY().
85
86 $obj->NEXTKEY(PREVIOUS)
87
88 FIRSTKEY() returns the first message-id/message pair from the
89 folder, and NEXTKEY returns the message-id/message pair for the
90 next message, in the order in which the message is stored in the
91 folder.
92
93 Messages flagged for deletion will not be returned. See the
94 Mail::Box::messages() method of the folder type for more informa‐
95 tion about the folder message order.
96
97 Example:
98
99 foreach my $msgid (keys %inbox) ...
100 foreach my $msg (values %inbox) ...
101
102 while(my ($msgid, $msg) = each %inbox) {
103 $msg->print unless $msg->isDeleted;
104 }
105
106 $obj->STORE(undef, MESSAGE)
107
108 Store a message in the folder. The key must be "undef", because
109 the message-id of the specified message is taken. This is shown in
110 the first example. However, as you see, it is a bit complicated to
111 specify "undef", therefore the string "undef" is accepted as well.
112
113 The message may be converted into something which can be stored in
114 the folder type which is at stake. The added instance is returned.
115
116 Example:
117
118 $inbox{ (undef) } = $msg;
119 $inbox{undef} = $msg;
120
122 This module is part of Mail-Box distribution version 2.070, built on
123 March 25, 2007. Website: http://perl.overmeer.net/mailbox/
124
126 Copyrights 2001-2007 by Mark Overmeer.For other contributors see
127 ChangeLog.
128
129 This program is free software; you can redistribute it and/or modify it
130 under the same terms as Perl itself. See
131 http://www.perl.com/perl/misc/Artistic.html
132
133
134
135perl v5.8.8 2007-03-25 Mail::Box::Tie::HASH(3)