<<

NAME

UCS::DS::Format - ASCII-format data set or subset

SYNOPSIS

  use UCS::DS::Memory;
  use UCS::DS::Format;

  $ds = new UCS::DS::Memory $filename;  # needs in-memory representation

  $formatter = new UCS::DS::Format $ds; # formatter object for data set $ds

  $formatter->digits(6);                # number of significant digits 

  $formatter->mode("table");            # only mode so far

  $formatter->pagelength(50);           # print in pages of 50 rows each
  $formatter->pagelength(undef);        # print as single table

  $formatter->vars($pattern, ...);      # select variables that will be shown

  $formatter->print;                    # print formatted table on STDOUT
  $formatter->print($filename);         # write to file or pipe

DESCRIPTION

This module provides a convenient method to format data sets as ASCII tables, which can then be used for viewing and printing. The formatter has to be applied to the in-memory representation implemented by the UCS::DS::Memory module. Its output is printed on STDOUT by default, but it can also be redirected to a file or pipe.

METHODS

$formatter = new UCS::DS::Format $ds;

Creates new formatter object for the data set $ds, which must be a UCS::DS::Memory object. The formatter object should be used immediately after its creation and destroyed afterwards. When any changes are made in the data set $ds, a new formatter has to be created.

$formatter->digits($n);

Configure $formatter to display approximately $n significant digits for floating-point variables (data type DOUBLE). $n must be at least 2.

$formatter->mode("table");

The default mode table prints the data set in the form of a simple ASCII table with column headers. It is the only supported mode so far.

$formatter->pagelength($rows);

Configure $formatter to format data set in separate pages of $n rows each. The individual pages are separated by a single blank line. Use of this option may improve the formatting quality, helps to avoid excessive columns widths, and reduces the delay before partial results can be displayed.

When $rows is set to 0 or omitted, the entire data set is printed as a single table. This is also the default behaviour.

$formatter->vars($pattern, ...);

Display only variables matching the specified wildcard patterns, in the specified order. This configuration option can also be used to change the ordering of the columns or display a variable in more than one column. Repeated calls to the vars method will overwrite, rather than add to, the previous selection.

$formatter->print;
$formatter->print($filename);

Format the data set with the specified options, and print the result on STDOUT. When the optional argument $filename is specified, the output is redirected to this file or pipe.

SEE ALSO

See also the manpage of the PRINT utility, which is based on the UCS::DS::Format module.

COPYRIGHT

Copyright 2004 Stefan Evert.

This software is provided AS IS and the author makes no warranty as to its use and performance. You may use the software, redistribute and modify it under the same terms as Perl itself.

<<