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