NAME

oEdtk::Spool - Helper module for parsing printer spool files

SYNOPSIS

use oEdtk::Main;
use oEdtk::Spool;

prodEdtkOpen($ARGV[0], $ARGV[1]);
my $s = oEdtk::Spool->new(\*IN, \*OUT);
$s->parse(\&process);

...

prodEdtkClose($ARGV[0], $ARGV[1]);

sub process($$) {
  my ($s, $line) = @_;
  
  if ($s->{'inres'} eq 'XYZ') {
    ...
  } else {
    ...
  }
}

DESCRIPTION

This module handles the repetitive tasks associated with the parsing of spool files: it extracts the identifiers of the resource blocks, the channel jumps, and passes this information along with the current line to a callback function. As a result, the first four characters of the original line from the stream are stripped.

METHODS

new

The new method creates a Spool object given two filehandles: the first one for input, and the second one for output. However, the second filehandle is currently unused since we now use the oEdtk::C7Doc module for handling output.

parse

The parse method takes a function reference as a parameter, and calls this function for each line of the input file, passing it the Spool object as the parameter, and the current line as the second parameter. The first four characters of the original line from the stream are stripped.

emit

The emit method is deprecated and should not be used in new code.

ATTRIBUTES

$s->{'inres'}

The identifier of the current resource block.

$s->{'prev_inres'}

The identifier of the previous resource block.

$s->{'numln'}

The current line number (starting at 1) in the resource block.

$s->{'jump'}

The channel jump, if any.

$s->{'state'}

A hash reference used as a state within the scope of a resource block. It will be emptied before the callback function is called at the beginning of each resource block.

SEE ALSO

oEdtk::Main, oEdtk::C7Doc

COPYRIGHT

Copyright 2009 - Maxime Henrion <mhenrion@gmail.com>