NAME Tie::JournaledFile - hash operation for a jurnaled style log file. SYNOPSIS use Tie::JournaledFile; $db = new Tie::JournaledFile { file => 'cache.txt' }; # get all entries with the key = 'rudo' @values = $db->find( 'rudo' ); or access in hash style use Tie::JournaledFile; tie %db, 'Tie::JournaledFile', { file => 'cache.txt' }; print $db{ rudo }, "\n"; where the format of "cache.txt" is key value (key\s+value) for each line. For example rudo teddy bear kenken north fox ..... If you specify match_condition as "last", FETCH() returns the first value with the key. It means "last match". If you specify match_condition as "first", it behaves as "first match". "last match" by default. use Tie::JournaledFile; tie %db, 'Tie::JournaledFile', { match_condition => "first", file => 'cache.txt', }; print $db{ rudo }, "\n"; If you get the latest value for $key, specify "last" by match_condition. The returned value is the last matched line with the key in the file. WHEN YOU USE "FIRST MATCH" ? From the view of journalized data, the last written data is valid, so "last match" condition is fundamental. When "first match" condition can be used ? The first match is meaningfull only when you need to check the existence of the primary key regardless of the vlaue. KNOWN BUGS YOU CANNOT USE SPACE (\s+) IN THE KEY. METHODS TIEHASH, FETCH, STORE, FIRSTKEY, NEXTKEY standard hash functions. get_all_values_as_hash_ref() return a set of { key => value } for all keys. The returned value is HASH REFERECE for the KEY as follows: KEY => [ VALUE1, VALUE2, VALUE3, ]; not KEY => VALUE by default. find(key, [ $mode ]) return the array of line(s) with the specified "key". The line is either first or last mached line. The maching strategy is determined by "match_condition" parameter at "new()" method. "last match" by default. CODING STYLE See "http://www.fml.org/software/FNF/" on fml coding style guide. AUTHOR Ken'ichi Fukamachi COPYRIGHT Copyright (C) 2001,2002,2003,2004,2005 Ken'ichi Fukamachi All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. HISTORY Tie::JournaledFile first appeared in fml8 mailing list driver package. See "http://www.fml.org/" for more details.