Text::Structured - Manipulate fixed-format pages
use Text::Structured; $st = new Text::Structured($page); $foo = $st->get_text_at($r,$c,$len); $foo = $st->get_text_re($r,$re);
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).
Text::StructuredBase
Create a new Text::Structured object. $page is a string containing a page of text.
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.
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.
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!'.
Paul Sharpe <paul@miraclefish.com>
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.
To install Text::Structured, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Structured
CPAN shell
perl -MCPAN -e shell install Text::Structured
For more information on module installation, please visit the detailed CPAN module installation guide.