PICA::Patch - Implementation of PICA diff and patch
This file contains the implementation of diff and patch algorithm for PICA+ records. See functions pica_diff and pica_patch (or object methods diff and patch) of PICA::Data for usage.
pica_diff
pica_patch
diff
patch
The difference between two records or the change to be applied to a record is referred to as diff, delta or patch. In any case the format must encode a set of modifications. PICA Patch format encodes modifications to PICA records in form of annotated PICA records. PICA fields can be annotated with:
To denote a field that should be added.
To denote a field that should be removed.
To denote a field that should be kept as it is.
Modification of a field can be encoded by removal of the old version followed by addition of the new version.
Given a PICA record with two fields:
| 003@ $012345 | 021A $aA book
A diff to modify the second field could be this:
| - 021A $aA book | + 021A $aAn interesting book
The diff could be extended with the first field to make sure it can only applied if the first field exists in the record:
| 003@ $012345 | - 021A $aA book | + 021A $aAn interesting book
Records are always sorted before application of diff or patch. Records must be limited to one level and contain no sub-records.
Fields are not added with a patch if the records already contains a fully identical field.
Return the difference between two records as annotated record.
Apply a difference given as annotated PICA and return the result as new record. This function may die with an error method if the diff cannot be applied.
To install PICA::Data, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PICA::Data
CPAN shell
perl -MCPAN -e shell install PICA::Data
For more information on module installation, please visit the detailed CPAN module installation guide.