File Coverage

blib/lib/POSIX/Regex.pm
Criterion Covered Total %
statement 41 42 97.6
branch 4 6 66.6
condition 1 2 50.0
subroutine 10 10 100.0
pod 0 2 0.0
total 56 62 90.3


line stmt bran cond sub pod time code
1             package POSIX::Regex;
2              
3 6     6   39592 use strict;
  6         15  
  6         299  
4 6     6   34 use warnings;
  6         13  
  6         11943  
5 6     6   94 use Carp;
  6         19  
  6         468  
6              
7             require Exporter;
8 6     6   30 use base 'Exporter';
  6         12  
  6         2376  
9              
10             our %EXPORT_TAGS = ( all => [qw(
11             REG_EXTENDED
12             REG_ICASE REG_NEWLINE
13             REG_NOTBOL REG_NOTEOL
14             )]);
15              
16             our @EXPORT_OK = ( @{$EXPORT_TAGS{all}} );
17             our @EXPORT = ();
18              
19             our $VERSION = 1.0003;
20              
21             # AUTOLOAD {{{
22             sub AUTOLOAD {
23             # This AUTOLOAD is used to 'autoload' constants from the constant()
24             # XS function.
25              
26 7     7   4133 my $constname;
27 7         15 our $AUTOLOAD;
28 7         44 ($constname = $AUTOLOAD) =~ s/.*:://;
29 7 50       34 croak "&POSIX::Regex::constant not defined" if $constname eq 'constant';
30 7         62 my ($error, $val) = constant($constname);
31 7 50       26 if ($error) { croak $error; }
  0         0  
32             {
33 6     6   41 no strict 'refs';
  6         14  
  6         2113  
  7         13  
34 7     11   69 *$AUTOLOAD = sub { $val };
  11         52  
35             }
36 7         36 goto &$AUTOLOAD;
37             }
38             # }}}
39              
40             require XSLoader;
41             XSLoader::load('POSIX::Regex', $VERSION);
42              
43             sub new {
44 11     11 0 3520 my $class = shift;
45 11         32 my $this = bless {}, $class;
46 11   50     101 $this->{rt} = shift || "";
47              
48 11         22 my $opts = 0;
49 11         38 $opts |= $_ for @_;
50              
51 11         424 $this->regcomp($this->{rt}, $opts);
52              
53 10         29 return $this;
54             }
55              
56             sub match {
57 16     16 0 1842 my $this = shift;
58 16         27 my $str = shift;
59              
60 16         30 my $opts = 0;
61 16         44 $opts |= $_ for @_;
62              
63 16 100       41 return @{$this->regexec_wa( $str, $opts )} if wantarray;
  3         86  
64 13         332 return $this->regexec( $str, $opts );
65             }
66              
67 11     11   786 sub DESTROY { my $this = shift; $this->cleanup_memory; }
  11         551  
68              
69             1;