Subject: | Examples in pod do not work(?) Regexp::Common |
Date: | Mon, 13 May 2019 14:40:10 -0700 |
To: | bug-Regexp-Common [...] rt.cpan.org |
From: | Jim Avera <jim.avera [...] gmail.com> |
Hi,
The examples of using -flags in the documentation do not seem to work.
Or else the reader of the documenttion does not seem to work. Either
way, what's wrong with the following?
Thanks,
-Jim Avera
#!/usr/bin/perl
use strict; use warnings;
use Regexp::Common qw/pattern/;
# pattern copied and pasted from documentaion of Regexp::Common version
2017060201
pattern name => [ 'lineof', '-char=_' ],
create => sub {
my $flags = shift;
# gets "use of uninitialized values in quotemeta"
my $char = quotemeta $flags->{-char};
return '(?:^$char+$)';
},
match => sub {
my ($self, $str) = @_;
return $str !~ /[^$self->{flags}{-char}]/;
},
subs => sub {
my ($self, $str, $replacement) = @_;
$_[1] =~ s/^$self->{flags}{-char}+$//g;
},
;
$_ = "****";
/$RE{lineof}{-char=>'*'}/ or die "NOT MATCHED"; # dies here