Tie::Array::FileWriter - A Perl module for writing records to files as items are pushed onto a virtual array


Tie-Array-FileWriter documentation  | view source Contained in the Tie-Array-FileWriter distribution.

Index


NAME

Top

Tie::Array::FileWriter - A Perl module for writing records to files as items are pushed onto a virtual array

SYNOPSIS

Top

  use Tie::Array::FileWriter;
  my @output;
  tie @output, 'file.dat', ',', "\n"; # Write to file 'file.dat', use comma as field delimiter
  push @output, [ qw(a b c d) ];
  push @output, [ qw(e f g h) ];
  untie @output;

DESCRIPTION

Top

This is a write-only array that can only be written via push. It ignores anything pushed onto it that is not an array reference. Elements of array references are joined by the field delimiter and written to the output file, followed by the record delimiter.

You can write fixed-length records by ensuring the fields that are passed in are preformatted to thier desired fixed lengths and setting the field and record delimiters to empty strings.

The default field delimiter is the vertical bar ('|', also known as 'pipe'), and the default record delimiter is newline ("\n").

You can pass in either an already opened FileHandle object, or a file name. If you pass in a FileHandle object, the file will not be closed by Tie::Array::FileWriter.

AUTHOR

Top

Gregor N. Purdy <gregor@focusresearch.com>

COPYRIGHT

Top

LICENSE

Top

This program is free software. It is subject to the same license as Perl itself.


Tie-Array-FileWriter documentation  | view source Contained in the Tie-Array-FileWriter distribution.