1 package NonameTV
::StringMatcher
;
10 NonameTV::StringMatcher
15 my $sm = NonameTV::StringMatcher->new();
16 $sm->AddRegexp( qr/\bt.st\b/, [ 1,2 ] );
18 my $res = $sm->Match( "this is a test" );
21 print $res->[0] . " " . $res->[1] . "\n";
32 The constructor for the object.
38 my $class = ref( $_[0] ) || $_[0];
48 Add a new regexp that all strings should be matched against.
49 Takes two parameters, the regexp to match against and the data
50 that should be returned if the match is successful.
59 push @
{$self->{regexps
}}, [$re,$res];
64 Match a string against all regexps in the object. Returns
65 the result for the first regexp that matches.
66 Takes a single parameter, the string to match against the regexps.
68 Returns undef if no regexp matches.
77 foreach my $r (@
{$self->{regexps
}})
92 Copyright (C) 2004 Mattias Holmlund.