Tie::Hash::TransUascetrioCnoanlt(r3i)buted Perl DoTciuem:e:nHtaasthi:o:nTransactional(3) NNNNAAAAMMMMEEEE Tie::Hash::Transactional - A hash with checkpoints and rollbacks SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS use Tie::Hash::Transactional tie my %transact_hash, 'Tie::Hash::Transactional'; %transact_hash = ( good => 'perl', bad => 'java', ugly => 'tcl' ); tied(%transact_hash)->checkpoint(); $transact_hash{indifferent} = 'C'; # hmmm ... must avoid controversial sample code, so ... tied(%transact_hash)->rollback(); DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN This module implements a hash with RDBMS-like transactions. You can checkpoint the hash (that is, you can save its current state), and you can rollback the hash (restore it to the previous saved state). You can checkpoint and rollback multiple times, as checkpointed states are saved on a stack. The following named parameters are supported: ""(none)"" Currently, no named parameters are supported. It is intended that future versions will use named parameters to let you apply this transactional grooviness to other tied hashes. MMMMEEEETTTTHHHHOOOODDDDSSSS The following methods are available. Call them thus: "tied(%my_hash)-"_m_e_t_h_o_d_n_a_m_e_(_);> ""checkpoint"" Saves the current state of the hash onto the stack, so that it can be retrieved later. ""commit"" Discards all saved states from the stack. Why bother? Well, if your transactional hash contains a lot of data, then if you have a load of checkpoints on the stack, then it's going to consume a vast amount of memory - each state on the stack is just a copy of the hash as it was when you checkpointed. Once you are sure that your hash contains the data you want it to 2001-06-13 perl v5.6.1 1 Tie::Hash::TransUascetrioCnoanlt(r3i)buted Perl DoTciuem:e:nHtaasthi:o:nTransactional(3) contain, and you no longer need any of the previous states, you can free a lot of memory of commiting. In a future version, which is intended to add support for making other types of tied hashes transactional, this method may do things too. ""rollback"" Retrieve the last saved state from the stack. Any changes you have made since the last checkpoint are discarded. It is a fatal error to rollback with nothing on the stack. BBBBUUUUGGGGSSSS Plenty, no doubt. Please tell me if you find any. AAAAUUUUTTTTHHHHOOOORRRR David Cantrell CCCCOOOOPPPPYYYYRRRRIIIIGGGGHHHHTTTT Copyright 2001 David Cantrell. This module is licensed under the same terms as perl itself. SSSSEEEEEEEE AAAALLLLSSSSOOOO _T_i_e_:_:_H_a_s_h(3) 2001-06-13 perl v5.6.1 2