|
Array::Stream::Transactional::Matcher - Perl extension for finding content in arrays |
use Array::Stream::Transactional::Matcher qw(mkrule);
use Array::Stream::Transactional;
my $stream = Array::Stream::Transactional->new([1,5,3,2,5,2,4,1,1,2,3,2,2]);
my $rule = mkrule(Flow::sequence => mkrule(Value::eq => 2), mkrule(Value::gt => 2));
my $matcher = Array::Stream::Transactional::Matcher->new(rules => [$rule]);
my @matches = $matcher->match($stream);
for(@matches) {
print "Found match at $_->{start} to $_->{end}\n";
}
Array::Stream::Transactional::Matcher allowes you to search an array for content based on arbitrary complex rules.
The return value is an array of hashes containing the keys rule which is a reference to the rule that matches, start is the offset within the stream that the match where found and end is the offset whinit the stream where the matching rule ended.
If a handler is supplied a handler or a default handler is supplied it is passed the matching rule, the start offset and end offset.
None by default.
Rules implementing logical operators such as and, or, xor, not are described in the Array::Stream::Transactional::Matcher::Logical manpage
Rules implementing value tests such as eq, ne, lt and so forth are described in the Array::Stream::Transactional::Matcher::Value manpage
Rules implementing flow os rules such as sequence, repetitions, optionals, switches are described in the Array::Stream::Transactional::Matcher::Flow manpage
A short description on how to write custom rules is available in the Array::Stream::Transactional::Rule manpage
Claes Jacobsson, claesjac@cpan.org
Copyright 2004 by Claes Jacobsson
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Array::Stream::Transactional::Matcher - Perl extension for finding content in arrays |