List-RewriteElements

 view release on metacpan or  search on metacpan

lib/List/RewriteElements.pm  view on Meta::CPAN

357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
=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

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
I<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

420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
provide 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 )