List-RewriteElements
view release on metacpan or search on metacpan
lib/List/RewriteElements.pm view on Meta::CPAN
357358359360361362363364365366367368369370371372373374375376377=item * C<file> or C<list>
The hash must hold either a C<file> element or a C<list> element -- but not
both! The value for the C<file> key must be an absolute path to an input
file. The value for C<list> must be a reference to an array in memory.
=item * C<body_rule>
The hash must have a C<body_rule> element whose value is a reference to a
subroutine providing a formula for the transformation of an individual record
in the incoming file to a record in the outgoing file. The first argument
passed to this subroutine must be the record from the incoming file. The
return value from this subroutine should be a string immediately ready for
printing to the output file (though the string should not end in a newline, as
printing will be handled by C<generate_output()>).
=item * C<body_suppress>
Optionally, you may provide a C<body_suppress> element whose value is a
reference to a subroutine providing a criterion according to which an
lib/List/RewriteElements.pm view on Meta::CPAN
382383384385386387388389390391392393394395396397398399400401402I<should> be output. The subroutine should simply C<
return
>, <i.e.>,
return
an implicit C<
undef
>,
when
the record should be omitted from the
outgoing file.
=item * C<header_rule>
Frequently the first row in a flat data file is a header row containing, say,
the names of the columns in a data table, joined by a delimiter. Because the
header row is different from all subsequent rows, you may optionally provide a
C<header_rule> element whose value is a reference to a
subroutine providing a formula for the transformation of the header row
in the incoming file to the header in the outgoing file. The first argument
passed to this subroutine must be the header row from the incoming file. The
return value from this subroutine should be a string immediately ready for
printing to the output file (though the string should not end in a newline, as
printing will be handled by C<generate_output()>).
=item * C<header_suppress>
Optionally, if you have provided a C<header_rule> element, you may provide
a C<header_suppress> element whose value is a
lib/List/RewriteElements.pm view on Meta::CPAN
420421422423424425426427428429430431432433434435436437438439440441442443444445provide an C<output_suffix> element and the outgoing file will be created in
the directory which is the I<current working directory> as of the point where
C<generate_output()> is called. An C<output_suffix> element will
be ignored
if
an C<output_file> element is provided.
=item * Note 1
If neither a C<header_rule> or C<header_suppress> element is provide to the
constructor, List::RewriteElements will treat the first row of the incoming
file the same as any other row, C<i.e.>, it will apply the C<body_rule>
transformation formula.
=item * Note 2
A C<body_suppress> or C<header_suppress> criterion, if present, will be
logically applied I<before> any C<body_rule> or C<header_rule> formula. We
don't apply the formula to transform a record if the record should not be
output at all.
=item * Note 3
=back
B<Return Value:> List::RewriteElements object.
=head2 C<generate_output()>
( run in 0.228 second using v1.01-cache-2.11-cpan-454fe037f31 )