The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tie::History - Perl extension giving scalars, arrays and hashes a history.

SYNOPSIS

  use Tie::History;

  my $scalartobj = tie($scalar, 'Tie::History');
  $scalar = "Blah blah blah";
  $tiedobject->commit;
  # If you don't have $tiedobject, you can use tied().
  tied($scalar)->commit; # Commit the change
  $scalar = "More more more";
  $tiedobject->commit; # Commit the change

  my $arraytobj = tie(@array,  'Tie::History');
  @array = qw/one two three/;
  $arraytobj->commit;

  my $hashtobj = tie(%hash,   'Tie::History');
  $hash{key} = "value";
  $hashtobj->commit;

METHODS

commit
  $scalartobj->commit;
  $arraytobj->commit;
  $hashtobj->commit;
  # Or if you don't have an object created
  tied($scalar)->commit;
  tied(@array)->commit;
  tied(%hash)->commit;

Commit the current value into the history.

previous
  $previous = $scalartobj->previous;
  @previous = $arraytob->previous;
  %previous = $hashobj->previous;
  # Or if you don't have an object created
  $previous = tied($scalar)->previous;
  @previous = tied(@array)->previous;
  %previous = tied(%hash)->previous;

Return the previous committed copy.

current
  $current = $scalartobj->current;
  @current = $arraytobj->current;
  %current = $hashtobj->current;
  # Or if you don't have an object created
  $current = tied($scalar)->current;
  @current = tied(@array)->current;
  %current = tied(%hash)->current;

Return the current copy, even if uncommitted.

get
  $first = $scalartobj->get(0);
  @first = $arraytobj->get(0);
  %first = $hashtobj->get(0);
  # Or if you don't have an object created
  $first = tied($scalar)->get(0);
  @first = tied(@array)->get(0);
  %first = tied(%hash)->get(0);

Return the copy in the position passed, starting with 0 as the first, and -1 as the last.

getall
  @all = $scalartobj->getall;
  @all = $arraytobj->getall;
  @all = $hashtobj->getall;
  # Or if you don't have an object created
  @all = tied($scalar)->getall;
  @all = tied(@array)->getall;
  @all = tied(%hash)->getall;

Return an array with all previous versions committed.

revert
  $scalartobj->revert(1);
  $arraytobj->revert(1);
  $hashtobj->revert(1);
  # Or if you don't have an object created
  tied($scalar)->revert(1);
  tied(@array)->revert(1);
  tied(%hash)->revert(1);

Will revert the tied variable back to what position passed. If nothing is passed, it will revert to the last committed item. If the last item committed item is the same as the current, it will revert to the previous item. This may change in the future.

DESCRIPTION

Tie::History will allow you to keep a history of previous versions of a variable, by means of committed the changes. As this is all stored in memory, it is not for use in a production system, but best kept for debugging.

EXPORT

None by default.

SEE ALSO

Tie::HashHistory

Tie::RDBM

AUTHOR

Larry Shatzer, Jr., <larrysh@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2004 by Larry Shatzer, Jr.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.