Tie::Array::FileWriter - A Perl module for writing records to files as items are pushed onto a virtual array
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;
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.
Gregor N. Purdy <gregor@focusresearch.com>
Copyright (C) 2001 Gregor N. Purdy. All rights reserved.
This program is free software. It is subject to the same license as Perl itself.
To install Tie::Array::FileWriter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Array::FileWriter
CPAN shell
perl -MCPAN -e shell install Tie::Array::FileWriter
For more information on module installation, please visit the detailed CPAN module installation guide.