NAME

Mail::Box::Tie - Acces an existing message-folder as array

SYNOPSIS

tie my @inbox, 'Mail::Box::File', file => $ENV{MAIL};
tie my @inbox, $folder;

foreach (@inbox) {print $_->short}
print $inbox[3];
push @inbox, Mail::Box::Message->new(...);
my $folder = tied @inbox;

DESCRIPTION

Read Mail::Box::Manager first. Folders certainly look as arrays, so why not just access them as one? Each folder is a sub-class of this class.

METHODS

Not all operations on arrays are supported. Actually, most functions which would reduce the size of the array are modified to signal messages as ready for removal.

Examples of what you can do:

tie my @inbox, 'Mail::Box::File', ...;
my $message = new Mail::Box::Message(...);

push @inbox, $message;
delete $inbox[2];         # becomes undef
$inbox[3]   = $message;
print $inbox[0]->status;
my $emails  = @inbox;
untie @inbox;             # calls write()

# Direct access to the Mail::Box object.
my $folder = tied @inbox;
$folder->synchonize;

Examples what you cannot do:

shift/unshift/pop/splice @inbox;
tie ARRAY, FOLDERTYPE, PARAMS
tie ARRAY, FOLDERTYPE, FOLDER

There are to ways to construct a tie. In the first case, you start with a tie, and may later ask for the tied folder structure. In the second version, you have first created a folder, and then put a tie around it.

The first version: tie an ARRAY to a folder of type FOLDERTYPE, where the constructor of the folder requires some parameters. Possible PARAMS are the parameters of the new constructor of the specified folder-type.

Example:

tie my(@inbox), 'Mail::Box::File', folder => $ENV{MAIL};
my $inbox = tied @inbox;

The second version: tie an ARRAY interface around an existing FOLDER. The type as specified with FOLDERTYPE is only used to find the correct TIEARRAY method, usually the result of ref FOLDER.

Example:

my $inbox = Mail::Box::File->new(folder => $ENV{MAIL});
tie my(@inbox), ref $inbox, $inbox;

IMPLEMENTED METHODS

This module implements TIEARRAY, FETCH, STORE, FETCHSIZE, DELETE, PUSH, and DESTROY.

This module does not implement all other methods as described in the Tie::Array manual-page.

AUTHOR

Mark Overmeer (Mark@Overmeer.net). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

VERSION

This code is beta, version 1.112