NAME

oEdtk::FixIdx - make every document of a CSV index span an even number of pages

SYNOPSIS

use oEdtk::FixIdx qw(make_docs_even_numbered);

make_docs_even_numbered($idx_file);   # rewrites $idx_file in place

DESCRIPTION

A CSV .idx index is a list of documents; a document is a run of rows whose pages are numbered from 1 to the total for that document. When a document has an odd number of pages, this module duplicates its last row so the document ends on an even number of pages, which is what recto/verso printing needs. Ported unchanged from the 0.8032 fork at S20 of the fork-merge plan.

FUNCTIONS

make_docs_even_numbered

my $rc = make_docs_even_numbered($in_file);

Read $in_file, make every document even, and write the result back over $in_file through a temporary file. Returns 0. The first row (the header) is copied through untouched.

loop_on_data_rows

loop_on_data_rows($csv_in, $csv_out, $fh_in, $fh_out);

Group consecutive rows by document (its IDLDOC.SEQDOC.IDDEST triple) and flush each group with "flush_seq_doc". Returns 0.

flush_seq_doc

flush_seq_doc($fh, $csv, $aoa);

Write one document (an array of arrays) to $fh with $csv, after making its page count even.

complete_seq_doc

my $aoa = complete_seq_doc($aoa);

Return $aoa unchanged when it already has an even number of rows, or a copy with one extra row ("add_one_page") otherwise.

add_one_page

my $aoa = add_one_page($aoa);

Return a copy of $aoa whose last row is duplicated: every row's total page count is incremented, and the duplicated row's page sequence numbers are bumped too.

AUTHOR

The oEdtk team.