Parse::Tokens - class for parsing text with embedded tokens
package MyParser; use base 'Parse::Tokens'; MyParser->new->parse({ text => q{Hi my name is <? $name ?>.}, hash => {name=>'John Doe'}, delimiters => [['<?','?>']], }); # override SUPER::token sub token { my( $self, $token ) = @_; # $token->[0] - left bracket # $token->[1] - contents # $token->[2] - right bracket # do something with the token... } # override SUPER::token sub ether { my( $self, $text ) = @_; # do something with the text... }
Parse::Tokens
HTML::Parser
Pass parameter as a hash reference. Options are specified in the getter/setter methods.
Flush the template cash.
Run the parser.
Turn on autoflushing causing the template cash (not the text) to be purged before each call to parse();.
Specify delimiters as an array reference pointing to the left and right delimiters. Returns array reference containing two array references of delimiters and escaped delimiters.
Turn on debug mode. 1 is on, 0 is off.
Sets/gets the callback code reference for the 'ether' event.
Allow any combination of delimiters to match. Default is turned of requiring exactly specified pair matches only.
Sets/gets the callback code reference for the 'post_parse' event.
Sets/gets the callback code reference for the 'pre_parse' event.
Add a delimiter pair (array ref) to the list of delimiters.
Load text.
Sets/gets the callback code reference for the 'token' event.
Event method that gets called when non-token text is encountered during parsing.
Event method that gets called after parsing has completed.
Event method that gets called prior to parsing commencing.
Event method that gets called when a token is encountered during parsing.
Cleanup of internal documentation.
Added support for callbacks. Improved debug messaging. Fixed bug in delimiter assignment. Rearranged distribution files.
Added sample script and sample data.
Fixed pseudo bug relation to regular expression 'o' option. Aliased 'add_delimiters' to 'push_delimiters'. Misc internal changes.
Add push_delimiters method for adding to the delimiter array.
Add pre_parse and post_parse methods; add minimal debug message support.
Add multi-token support.
Steve McKay, steve@colgreen.com
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).
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Parse::Tokens, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Tokens
CPAN shell
perl -MCPAN -e shell install Parse::Tokens
For more information on module installation, please visit the detailed CPAN module installation guide.