/usr/share/perl5/Regexp/RegGrp/Data.pm is in libregexp-reggrp-perl 1.002001-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | package Regexp::RegGrp::Data;
use 5.008009;
use warnings;
use strict;
use Carp;
our @ACCESSORS = ( 'regexp', 'replacement', 'store', 'restore_pattern' );
##########################################################################################
{
no strict 'refs';
foreach my $field ( @ACCESSORS ) {
next if defined *{'Regexp::RegGrp::Data::' . $field}{CODE};
*{'Regexp::RegGrp::Data::' . $field} = sub {
my $self = shift;
return $self->{'_' . $field};
};
}
}
sub new {
my ( $class, $in_ref ) = @_;
my $self = {};
bless( $self, $class );
unless ( $in_ref->{regexp} ) {
carp( 'Value for key "regexp" must be a scalar or a regexp object!' );
return;
}
foreach my $accessor ( @ACCESSORS ) {
if ( $accessor eq 'regexp' || $accessor eq 'restore_pattern' ) {
if (
ref( $in_ref->{$accessor} ) and
ref( $in_ref->{$accessor} ) ne 'Regexp'
) {
carp( 'Value for key "' . $accessor . '" must be a scalar or a regexp object!' );
return;
}
}
elsif ( $accessor eq 'replacement' || $accessor eq 'store' ) {
if (
ref( $in_ref->{$accessor} ) and
ref( $in_ref->{$accessor} ) ne 'CODE'
) {
carp( 'Value for key "' . $accessor . '" must be a scalar or a code reference!' );
return;
}
}
}
if ( ref( $in_ref->{modifier} ) ) {
carp( 'Value for key "modifier" must be a scalar!' );
return;
}
$self->{_regexp} = $in_ref->{regexp};
$self->{_replacement} = defined( $in_ref->{store} ) ? (
$in_ref->{restore_pattern} ? $in_ref->{replacement} : sub {
return sprintf( "\x01%d\x01", $_[0]->{store_index} );
}
) : $in_ref->{replacement};
$self->{_store} = $in_ref->{store};
if ( defined( $in_ref->{modifier} ) || ! ref( $in_ref->{regexp} ) ) {
my $modifier = defined( $in_ref->{modifier} ) ? $in_ref->{modifier} : 'sm';
$self->{_regexp} =~ s/^\(\?[\^dlupimsx-]+:(.*)\)$/$1/si;
$self->{_regexp} = sprintf( '(?%s:%s)', $modifier, $self->{_regexp} );
}
my $restore_pattern = $in_ref->{restore_pattern} || qr~\x01(\d+)\x01~;
$self->{_restore_pattern} = qr/$restore_pattern/;
return $self;
}
1;
|