line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Regexp.pm,v 1.10 2003/06/06 18:45:02 unimlo Exp $ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::ACL::Match::Regexp; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw( $VERSION @ISA ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
## Inheritance and Versioning ## |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
@ISA = qw( Net::ACL::Match::Scalar ); |
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
## Module Imports ## |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use Net::ACL::Match::Scalar; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
18
|
1
|
|
|
1
|
|
5
|
use Net::ACL::Rule qw( :rc ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
96
|
|
19
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
118
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## Public Object Methods ## |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub match |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
26
|
0
|
|
|
|
|
|
my $pattern = $this->{_value}; |
27
|
0
|
|
|
|
|
|
my $data = $_[$this->{_index}]; |
28
|
0
|
0
|
|
|
|
|
return $data =~ /$pattern/ ? ACL_MATCH : ACL_NOMATCH; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
## POD ## |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Net::ACL::Match::Regexp - Class matching a scalar data element |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use Net::ACL::Match::Regexp; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Construction |
44
|
|
|
|
|
|
|
my $match = new Net::ACL::Match::Regexp(['^65001 [0-9 ]+ 65002$', 2]); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Accessor Methods |
47
|
|
|
|
|
|
|
$rc = $match->match(@data); # same as: $data[1] eq 42 ? ACL_MATCH : ACL_NOMATCH; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This module is a very simple array element testing with regular expression |
52
|
|
|
|
|
|
|
utility to allow simple value matching with L. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $match = new Net::ACL::Match::Regexp(['^65001 [0-9 ]+ 65002$',2]); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is the constructor for Net::ACL::Match::Regexp objects. |
59
|
|
|
|
|
|
|
It returns a reference to the newly created object. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
It takes one argument. If the argument is a array reference with one element, |
62
|
|
|
|
|
|
|
the element will be used as a regular expression pattern to matched with the first |
63
|
|
|
|
|
|
|
argument to the match method. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
If an array reference has more then one element, the second element should be |
66
|
|
|
|
|
|
|
the argument number to be matched in the match method. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Otherwise, the value it self will be used as a regular expression pattern to match the |
69
|
|
|
|
|
|
|
first argument of the match method. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 ACCESSOR METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
I |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This function matches the arguments according to the arguments of the |
76
|
|
|
|
|
|
|
constructor and returns either C or C as exported by |
77
|
|
|
|
|
|
|
Net::ACL::Rule with C<:rc>. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SEE ALSO |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Net::ACL::Match, Net::ACL::Rule, Net::ACL |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Martin Lorensen |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
## End Package Net::ACL::Match::Regexp ## |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |