List::History - a previous/current/next list of objects
This is a history list much like what is implemented in most major browsers.
The position pointer could be in one of several states:
prev current next ------- ------- -------- 0 0 0 just started 1 0 0 clicked a new link 0 1 1 clicked once and went back 1 1 0 went back (or forward to end) 1 1 1 went back twice or more
In other words, there is not a current moment unless you remember() it. The state is saved just before the user leaves the current page.
remember()
my %details = ( foo => 1, # gives moment foo(), get_foo(), and set_foo() bar => 1, # etc. ); my $hist = List::History->new(moment_spec => {%details});
The moment_spec argument defines the attributes for the moment class, which allows you to use accessors on the stored hashref. Each moment class is particular to a given history object. This is generated for you by the constructor. The values in the hash are currently ignored, but will eventually become some sort of typemap.
moment_spec
Add a moment to the history. $hist->has_current will always be false after this method is called.
$hist->has_current
$hist->add(%moment_data);
Creates a moment and either replaces the current moment or else makes this one current. (You'll need to call this before going back.)
$hist->remember(%moment_data);
These return true if the history has a moment in the given slot.
my $bool = $hist->has_current;
my $bool = $hist->has_next;
my $bool = $hist->has_prev;
my $moment = $hist->foreward;
my $moment = $hist->backward;
my @list = $hist->get_list;
my $moment = $hist->get_current;
my $moment = $hist->get_moment($index);
This is called automatically by add(). Clears the current and future item.
add()
$hist->clear_future;
This will typically not be needed since add() and remember() call it for you.
my $moment = $self->moment(%moment_data);
my $list = $hist->_list;
$self->_inc_pos($number);
Eric Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com/
Copyright (C) 2006 Eric L. Wilhelm and OSoft, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install dtRdr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm dtRdr
CPAN shell
perl -MCPAN -e shell install dtRdr
For more information on module installation, please visit the detailed CPAN module installation guide.