Fsdb::IO::Writer - handle formatting reading from a fsdb file (handle) or queue
$fsdb = new Fsdb::IO::Writer(-file => $filename); $fsdb = new Fsdb::IO::Writer(-header => "#fsdb -F t foo bar", -fh => $file_handle); $fsdb = new Fsdb::IO::Writer(-file => '-', -fscode => 'S', -cols => [qw(firstcol second)]); # or to add a column to a prior file $in = new Fsdb::IO::Reader(-file => '-'); $out = new Fsdb::IO::Writer(-clone => $in, -outputheader => 'delay'); $out->col_create('new_column');
Creates a new writer object. Always succeeds, but check the error method to test for failure.
error
Options:
-file
-header
If value is "now" (the default), the header is generated after option parsing. If "delay", it is generated on first data record output. If "never", no header is ever output, and output will then not be fsdb format. If it is a perl subroutine, then the format_sub() is called to generate the header on the first data record output (like delay); it should return the string for the header.
format_sub()
documented in new
$self->_enable_compression
internal use only: switch from uncompressed to compressed.
$self->create_io_subs($with_compression)
internal use only: create a thunk that writes rowobjs.
internal use only; write the header.
As a side-effect, we also instantiate the _write_io_sub.
$fsdb->write_rowobj($rowobj);
Write a "row object" to an outpu stream. Row objects are either a scalar string, for a comment or header, or an array reference for a row. This routine is the fastest way to do full-featured fsdb-formatted IO. (Although see also Fsdb::Writer::fastpath_sub.)
$fsdb->write_row_from_aref(\@a);
Write @a.
$fsdb->write_row($a1, $a2...);
Write args out. Less efficient than write_row_from_aref.
$fsdb->write_row_from_href(\%h);
Write out %h, a hash of the row fields where each key is a field name.
$fsdb->fastpath_ok();
Check if we can do fast-path IO (header written, no errors).
$fsdb->fastpath_sub()
Return an anonymous sub that does fast-path rowobj writes when called.
$fsdb->close;
Close the file and kill the saved writer sub.
$fsdb->write_comment($c);
Write out $c as a comment. ($c should be just the text, without a "# " header or a newline trailer.
$fsdb->write_raw($c);
Write out $c as raw output, typically because it's a comment that already has a "#" in front and a newline at the rear.
format_fsdb_fields(\%data, \@fields)
Returns a string representing double-space-separated, formatted version of the hash'ed fields stored in %data, listed in @fields. (This routine is a hack, there needs to be a FsdbWriter to do this properly, but there isn't currently.
To install Fsdb, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fsdb
CPAN shell
perl -MCPAN -e shell install Fsdb
For more information on module installation, please visit the detailed CPAN module installation guide.