NAME
Pugs::Runtime::Match - Match object
SYNOPSIS
use Pugs::Compiler::Rule;
my $rule = Pugs::Compiler::Rule->compile( '((.).).' );
my $match = $rule->match( 'abc' );
if ($match) { # true
print $match; # "abc"
print $match->from; # 0
print $match->to; # 3
print $match->[0]; # "ab"
print $match->[0][0]; # "a"
}
OVERLOAD INTERFACE
bool
When used as a boolean, the match object returns whether the match has succeeded or not.
@{}
When used as an array reference, the match object returns positional captures as match objects.
%{}
When used as a hash reference, the match object returns named captures as match objects, keyed by their names.
&{}
When used as a code reference, the match object returns the result object; this is normally the entire match string, but may be arbitrary objects returned from the rule using a return
clause.
""
When used as a string, the match object returns the stringified version of the result object (usually the entire match string).
0+
When used as a number, the match object returns the numified version of the result object (usually the entire match string).
METHODS
from ()
Returns the initial position of the match.
to ()
Returns the final position of the match.
AUTHORS
The Pugs Team <perl6-compiler@perl.org>.
COPYRIGHT
Copyright 2006 by Flavio Soibelmann Glock and others.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.