NAME

PICA::Filemap - Map between files and record ids

DESCRIPTION

Experimental module to map between files and record ids.

METHODS

new ( $mapfile )

Opens a new filemap with a given filename or handle (IO::Handle). Use '-' for STDIN/STDOUT. The map is not read or written unless you call it with the methods read/write.

parseline ( $line )

Parses a map file line into timestamp, filename, and id and returns this three values in an array. Timestamp and id can be undef. A map file line contains one to three whitespace seperated values per line:

filename
filename id
timestamp filename
timestamp filename id

A timestamp must be an ISO 8601 timestamp that matches YYYY-MM-DDThh:mm:ss. If a filename contains a '%' character, it is URI unescaped. Comments can be added starting with '#'. If a line is empty or could not be parsed, the filename element in the return list is undef.

createline ( [ $timestamp, ] $filename [, $id ] )

Create a map file line with timestamp (optional), filename, and id (optional). Filenames are URI escaped.

write ( )

Write the map to a file or file handle. Returns the number of written entries.

read ( )

Read the map from a file and file handle. Returns the number of read entries.

size ( )

Return the number of files in this map.

file2id ( $filename )

Get the id of a file or undef if the file or its id was not found in the map.

id2file ( $id )

Get the file of a given id or undef if the id was not found in the map.

files ( [ $id_or_filename [, $id_or_filename...] ] )

Return list of all files in this map. In addition you can filter the list by ids/and or file.

ids ( [ $id_or_filename [, $id_or_filename...] ] )

Return a list of all ids in this map or all ids of a given set of ids and/or filenames.

outdated

Return whether a given file in the map has been changed since the last timestamp. A file without timestamp is always outdated.

create ( $filename, $id )

Add a file in the map with given filename and id.

update ( $filename, $id )

Update a file in the map with given filename and id.

delete ( $id )

Remove a file from the map by given id.

clean ( )

Clean the map by removing all files that do not exist anymore. Returns a list of removed files.

add ( $file(s) )

Add one or more files to the map if they do exist and are not already in the map. Returns a list of added files.

Utility function

unencoded_path ( $string )

Unencode a full path.

unencoded ( $string )

Remove URI-encoding (if '%' in the name) and return in UTF-8.

encode_path ( $string )

Encode a full path.

timestamp ( [ $time ] )

Returns an ISO 8601 timestamp of the form YYYY-MM-DDThh:mm:ss.

AUTHOR

Jakob Voss <jakob.voss@gbv.de>

LICENSE

Copyright (C) 2007-2009 by Verbundzentrale Göttingen (VZG) and Jakob Voß

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 427:

Non-ASCII character seen before =encoding in 'Göttingen'. Assuming UTF-8