1Mail::Mbox::MessageParsUesre:r:CCaocnhter(i3b)uted PerlMDaoiclu:m:eMnbtoaxt:i:oMnessageParser::Cache(3)
2
3
4
6 Mail::Mbox::MessageParser::Cache - A cache-based mbox folder reader
7
9 #!/usr/bin/perl
10
11 use Mail::Mbox::MessageParser;
12
13 my $filename = 'mail/saved-mail';
14 my $filehandle = new FileHandle($filename);
15
16 # Set up cache
17 Mail::Mbox::MessageParser::SETUP_CACHE(
18 { 'file_name' => '/tmp/cache' } );
19
20 my $folder_reader =
21 new Mail::Mbox::MessageParser( {
22 'file_name' => $filename,
23 'file_handle' => $filehandle,
24 'enable_cache' => 1,
25 } );
26
27 die $folder_reader unless ref $folder_reader;
28
29 warn "No cached information"
30 if $Mail::Mbox::MessageParser::Cache::UPDATING_CACHE;
31
32 # Any newlines or such before the start of the first email
33 my $prologue = $folder_reader->prologue;
34 print $prologue;
35
36 # This is the main loop. It's executed once for each email
37 while(!$folder_reader->end_of_file());
38 {
39 my $email = $folder_reader->read_next_email();
40 print $email;
41 }
42
44 This module implements a cached-based mbox folder reader. It can only
45 be used when cache information already exists. Users must not instantiā
46 ate this class directly--use Mail::Mbox::MessageParser instead. The
47 base MessageParser module will automatically manage the use of cache
48 and non-cache implementations.
49
50 METHODS AND FUNCTIONS
51
52 The following methods and functions are specific to the
53 Mail::Mbox::MessageParser::Cache package. For additional inherited
54 ones, see the Mail::Mbox::MessageParser documentation.
55
56 $ref = new( { 'file_name' => <mailbox file name>, 'file_handle' =>
57 <mailbox file handle>, });
58 <file_name> - The full filename of the mailbox
59 <file_handle> - An opened file handle for the mailbox
60
61 The constructor for the class takes two parameters. file_name is
62 the filename of the mailbox. This will be used as the cache key, so
63 it's important that it fully defines the path to the mailbox. The
64 file_handle argument is the opened file handle to the mailbox. Both
65 arguments are required.
66
67 Returns a reference to a Mail::Mbox::MessageParser object, or a
68 string describing the error.
69
71 No known bugs.
72
73 Contact david@coppit.org for bug reports and suggestions.
74
76 David Coppit <david@coppit.org>.
77
79 This software is distributed under the terms of the GPL. See the file
80 "LICENSE" for more information.
81
83 This code was originally part of the grepmail distribution. See
84 http://grepmail.sf.net/ for previous versions of grepmail which
85 included early versions of this code.
86
88 Mail::Mbox::MessageParser
89
90
91
92perl v5.8.8 2007-01-11Mail::Mbox::MessageParser::Cache(3)