Johan Vromans > Text-Filter > Text::Filter::Cooked

Download:
Text-Filter-1.9.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.02   Source  

NAME ^

Text::Filter::Cooked - Cooked reader for input files

SYNOPSIS ^

  use Text::Filter::Cooked;
  my $f = Text::Filter::Cooked->new
    (input => 'myfile.dat',
     comment => "#",
     join_lines => "\\");

  while ( my $line = $f->readline ) {
      printf("%3d\t%s\n", $f->lineno, $line);
  }

DESCRIPTION ^

Text::Filter::Cooked is a generic input reader. It takes care of a number of things that are commonly used when reading data and configuration files.

Text::Filter::Cooked is based on Text::Filter, see Text::Filter.

CONSTRUCTOR ^

The constructor is called new() and takes a hash with attributes as its parameter.

The following attributes are recognized and used by the constructor, all others are passed to the base class, Text::Filter.

ignore_empty_lines

If true, empty lines encountered in the input are ignored.

ignore_leading_whitespace

If true, leading whitespace encountered in the input is ignored.

ignore_trailing_whitespace

If true, trailing whitespace encountered in the input is ignored.

compress_whitespace

If true, multiple adjacent whitespace are compressed to a single space.

join_lines

This must be set to a string. Input lines that end with this string (not taking the final line ending into account) are joined with the next line read from the input.

comment

This must be set to a string. Input lines that start with this string are ignored.

Assume the input file to have this encoding.

Setting input_encoding will enable automatic and transparant handling of different file encodings, see "INPUT ENCODING".

METHODS ^

All attributes have set and get methods, e.g., set_comment and get_input_encoding.

Other methods:

readline

Read a single line of input. If line ignoring is in effect, the operation will be repeated internally until there is data to return.

lineno

Returns the number of the last line that was read from the input.

is_eof

Returns true iff the last record from the input has been read.