Array::Stream::Transactional - Transactional array wrapper
use Array::Stream::Transactional; my $stream = Array::Stream::Transactional->new([1..100]); $stream->commit; while($stream->has_more) { if($stream->next == 50 && !$reverted) { $stream->rollback; $reverted = 1; } print $stream->current, "\n"; }
Array::Stream::Transactional is a Perl extension for wrapping an array and having it pose as a stream. The streams current position can be commited and rollbacked at any time.
Creates an Array::Stream::Transactional. Wrapps the passed array reference. Position is set to 0, current is set the first element in ARRAYREF, previous is set to undef and the transaction stack is empty.
Array::Stream::Transactional
Get the next element from the stream and increment the position in the current transaction.
Get the previous element from the stream and decrement the position in the current transaction.
Get the current element read from the stream in the current transaction.
Get the previous element read from the stream in the current transaction.
Get the following element read from the strean in the current transaction. This method is like "next" except it doesn't increment the position.
Return the current position in the stream.
Return the length of the wrapped array
Return true if there are more elements in the stream, false otherwise.
Push the current position, element and previous element on the transaction stack.
Rollback the current transaction by reseting the stream position, current and previous element. The transaction will be removed from the transaction stack so that next rollback will rollback to the commit previous to the commit that created the rollbacked transaction.
Removes the top item of the commit stack. Returns the position, current element and previous element of the stream at the time the commit was made.
Resets the reading of the stream to position 0, current to first element and previous to undefined.
Claes Jacobsson, claesjac@cpan.org
Copyright 2004 by Claes Jacobsson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
=pod directives shouldn't be over one line long! Ignoring all 2 lines of content
To install Array::Stream::Transactional, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Array::Stream::Transactional
CPAN shell
perl -MCPAN -e shell install Array::Stream::Transactional
For more information on module installation, please visit the detailed CPAN module installation guide.