NAME

Parse::Tokens - class for parsing text with embedded tokens

SYNOPSIS

use Parse::Tokens;
@ISA = ('Parse::Tokens');

# overide SUPER::token
sub token
{
  my( $self, $token ) = @_;
  # $token->[0] - left bracket
  # $token->[1] - contents
  # $token->[2] - right bracket
  # do something with the token...
}

# overide SUPER::token
sub ether
{
  my( $self, $text ) = @_;
  # do something with the text...
}

DESCRIPTION

Parse::Tokens provides a base class for parsing delimited strings from text blocks. Use Parse::Tokens as a base class for your own module or script. Very similar in style to HTML::Parser.

Functions

new()

Initializes a Parse::Tokens object. Pass parameter as a hash reference. Options are: text - a block of text, delimiters - an array reference consisting of the left and right token delimiters (eg ['<?', '?>']), autoflush - 0(default) or 1, While these are all optional at initialization, both 'text' and 'delimiters' are required prior to or when calling the parse() method.

delimiters()

Specify delimiters as an array reference pointing to the left and right delimiters. Returns a two-part array containing two array references of the real (origional) and the escaped (internal) delimiters.

text()

Load the text to be parsed. Flushes any existing text.

parse()

Run the parser. Accepts an hash reference with initialization parameters.

flush()

Flush the template cash. This happens automatically when new text is provided to the module.

autoflush()

Turn on autoflushing causes Parse::Tokens to reparse the template text on every call to parse().

CHANGES

delimiters() now returns an array of real, escaped delimiters. This is different that previous behavior where an array reference was returned.

AUTHOR

Steve McKay, steve@colgreen.com

COPYRIGHT

Copyright 2000-2001 by Steve McKay. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl(1).