NAME
Text::Structured - Manipulate fixed-format pages
SYNOPSIS
use Text::Structured;
$st = new Text::Structured($page);
$foo = $st->get_text_at($r,$c,$len);
$foo = $st->get_text_re($r,$re);
DESCRIPTION
Text::Structured is a class for manipulating fixed-format pages of text. A page is treated as a series of rows and columns with the row and column of the top left hand corner of the page being (0,0).
SUPERCLASSES
Text::StructuredBase
CLASS METHODS
new($page)
Create a new Text::Structured object. $page is a string containing a page of text.
OBJECT METHODS
get_text_at($r,$c,$len)
Returns a substring of length $len starting at row $r, column $c. This method will die() if $r < 0 or $r > the number of lines in the page. See also "substr()" in perlfunc.
get_text_re($r,$re)
Returns a string which is the result of applying the regular expression $re to row $r of the page. This method will die() if $r < 0 or $r > the number of lines in the page.
do_method()
This method can be used with the Text::FillIn module (available from CPAN) to fill a template using methods from Text::Structured e.g.
use Text::FillIn;
use Text::Structured;
$page = q{foo bar
baz quux};
$st = new Text::Structured($page);
# set delimiters
Text::FillIn->Ldelim('(:');
Text::FillIn->Rdelim(':)');
$template = new Text::FillIn;
$template->object($st);
$template->hook('&','do_method');
$template->set_text(q{Oh (:&get_text_at(0,0,3):), it's a (:&get_text_re(1,(\w+)$):)!});
$foo = $template->interpret;
print "$foo\n";
Prints 'Oh foo, it's a quux!'.
AUTHOR
Paul Sharpe <paul@miraclefish.com>
COPYRIGHT
Copyright (c) 1999 Paul Sharpe. England. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.