blib/lib/Regexp/Genex.pm

filter: Statementstmt 76.3% 181 / 237 Branchbran 69.4% 25 / 36 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 35 / 49 Podpod 100% 4 / 4 totaltotal 73.5% 247 / 336 CC 21 SCAR 9.0
CC
21
Cov
75%
adjust_mods
7.5
new
6.0
add
4.1
CRAP 2.5
↑ Summary
1 package Regexp::Genex;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.07';
7  
8 1 our $MAX_QUANTIFIER = 20;
9 1 our $rx;
10 1 our $in = '';
11 1 our @stack = {
12 dot_nl => 0, # /s modifier
13 multiline => 0,# /m modifier
14 anycase => 0, # /i modifier
15 };
16  
17  
18 package Regexp::Genex::Element;
19 1 ▶use List::Util qw(shuffle);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 my $top = -1;
22  
23 # global status
24 124 ▶sub anycase {
Subroutine anycase: called CC=2 SCAR=6.9
25 124 ▶ return $stack[$top]{anycase} unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 86 38 124
26 38 $stack[$top]{anycase} = $_[1];
27 }
28  
29 77 ▶sub dot_nl {
Subroutine dot_nl: called CC=2 SCAR=6.9
30 77 ▶ return $stack[$top]{dot_nl} unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 39 38 77
31 38 $stack[$top]{dot_nl} = $_[1];
32 }
33  
34 77 ▶sub multiline {
Subroutine multiline: called CC=2 SCAR=6.9
35 77 ▶ return $stack[$top]{multiline} unless defined $_[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 39 38 77
36 38 $stack[$top]{multiline} = $_[1];
37 }
38  
39 38 ▶sub adjust_mods {
Subroutine adjust_mods: called CC=7 SCAR=20.1
40 38 my ($self, $on, $off) = @_;
41 38 ▶ $self->anycase(1) if $on =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $on =~ /i/ 20 18 38
42 38 ▶ $self->anycase(0) if $off =~ /i/;
Branch: 1 branch
BranchTrueFalseTotal
if $off =~ /i/ 18 20 38
43 38 ▶ $self->dot_nl(1) if $on =~ /s/;
Branch: 1 branch
BranchTrueFalseTotal
if $on =~ /s/ 0 38 38
44 38 ▶ $self->dot_nl(0) if $off =~ /s/;
Branch: 1 branch
BranchTrueFalseTotal
if $off =~ /s/ 38 0 38
45 38 ▶ $self->multiline(1) if $on =~ /m/;
Branch: 1 branch
BranchTrueFalseTotal
if $on =~ /m/ 0 38 38
46 38 ▶ $self->multiline(0) if $off =~ /m/;
Branch: 1 branch
BranchTrueFalseTotal
if $off =~ /m/ 38 0 38
47 }
48  
49 39 ▶sub push_state {
Subroutine push_state: called CC=1 SCAR=0.0
50 39 my ($self) = shift;
51 push @stack, {
52 # current state overwriten by new state
53 anycase => $self->anycase,
54 dot_nl => $self->dot_nl,
55 multiline => $self->multiline,
56 quant => $stack[$top]{quant},
57 39 @_, # new state
58 };
59 }
60 39 ▶sub pop_state {
Subroutine pop_state: called CC=2 SCAR=7.2
61 39 my ($self) = @_;
62 39 ▶ pop @stack or Carp::confess "Pop without a push";
Branch: 1 branch
BranchTrueFalseTotal
pop @Regexp::Genex::stack or Carp::confess("Pop without a push") 39 0 39
63 }
64  
65 246 ▶sub add {
Subroutine add: called CC=4 SCAR=14.2
66 246 my ($self, $code, $comment) = @_;
67  
68 246 $code = $in.$code;
69 246 ▶ if((my $len = length($code)) < 40) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $len = length $code) < 40) { } 242 4 246
70 # comment after code at col 40
71 242 $rx .= $code;
72 242 ▶ if(defined $comment) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $comment) { } 242 0 242
73 242 $rx .= (' 'x(40-$len))."## $comment\n";
74 } else {
75 0 $rx .= "\n";
76 }
77 } else {
78 # comment on line before code
79 4 ▶ $rx .= "\n".(' 'x40)."## $comment (below)\n" if defined $comment;
Branch: 1 branch
BranchTrueFalseTotal
if defined $comment 4 0 4
80 4 $rx .= "$code\n\n";
81 }
82 }
83  
84 92 ▶sub safe_quant {
Subroutine safe_quant: called CC=1 SCAR=0.0
85 92 my ($self, $quant) = @_;
86 # dodge perl's optimizations
87 92 my $nq = $quant;
88 #$nq =~ s/\*/{0,$MAX_QUANTIFIER}/;
89 #$nq =~ s/\+/{1,$MAX_QUANTIFIER}/;
90 92 return $nq;
91 }
92  
93 47 ▶sub case_mod {
Subroutine case_mod: called CC=2 SCAR=6.9
94 # i modifier in effect, use \u \L etc to muck with string at rx creation
95 47 ▶ return (!$_[0]->anycase) ? '' : ( "", qw(\U \L \u \l) )[rand 5];
Branch: 1 branch
BranchTrueFalseTotal
!$_[0]->anycase ? : 27 20 47
96 }
97  
98 # $; = undef ???
99 # keys = all characters, values = quoted string equivalent
100 # (String::Escape \80 != perl \x80)
101 1 my %all_chars = map { chr($_), '"'.escape(chr($_)).'"' } 0..255;
102  
103 # regex to pick random
104 # x "string" =~ /(?=(?>^.*(?{$n=int rand$+[0]})))(??{".{$n}"})(.)/s
105 5 ▶sub class_chars {
Subroutine class_chars: called CC=2 SCAR=7.5
106 5 my ($self, $qr_class) = @_;
107  
108 7 my @chars = map { $all_chars{$_} }
109 5 grep { $_ =~ $qr_class }
110 keys %all_chars;
111  
112 5 ▶ if(@chars > 10) { # too big, sample
Branch: 1 branch
BranchTrueFalseTotal
if (@chars > 10) 0 5 5
113 0 @chars = shuffle(@chars);
114 # XXX can't produce anything possible for regex .{$n+1} exhausts range
115 0 $#chars = 4;
116 # could put %all_chars generation in regex and do \d filter
117 }
118 5 return scalar(@chars), @chars;
119 }
120  
121 335 ▶sub escape {
Subroutine escape: called CC=1 SCAR=0.0
122 335 local($_) = shift;
123 335 s/([\\{}"@\$])/\\$1/g; # protect " string interpolation & {} regex parse
124 335 s/([^[:graph:] ])/sprintf "\\%03o", ord($1)/eg;
125 #s/(.*)/"$1"/s;
126 335 return $_;
127 }
128 #use String::Escape qw(qprintable);
129 #print qprintable($_)," = ",escape($_),"\n"
130 # for grep { $_ ne eval escape($_) } map chr, 0..255;
131  
132 package Regexp::Genex::flags;
133 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
134 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
135  
136 #my ($on, $off) = @_[1,2];
137 # ignore x, always on for us
138 # off overrides: perl -le 'print "A" =~ /(?i-i)a/'
139 0 $self->adjust_mods(@_[1,2]);
140
141 0 $self->add('',$self->string);
142 }
143  
144 package Regexp::Genex::group;
145 38 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
146 38 my $self = $_[0]->SUPER::new(@_[1..$#_]);
147  
148 38 $self->push_state(quant => $self->quant);
149 # modify new state
150 38 $self->adjust_mods(@_[1,2]);
151  
152 38 $self->add("(?:", $self->string);
153 38 $in .= ' '; # ->add_indent
154 38 return $self;
155 }
156  
157 package Regexp::Genex::capture;
158 1 my $number = 0;
159 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
160 1 my $self = $_[0]->SUPER::new(@_[1..$#_]);
161 1 $number++;
162 1 $self->push_state(quant => $self->quant);
163  
164 1 $self->add("(","( -> \$$number");
165 1 $in .= ' ';
166 1 return $self;
167 }
168  
169 package Regexp::Genex::close;
170 # group, capture, perl code bit
171 # Pcond Pcut Pahead Pbehind Pgroup Pcapture Pcode Plater
172 39 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
173 39 my $self = $_[0]->SUPER::new(@_[1..$#_]);
174 39 chop($in);
175 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
176 39 my $q = "$_[1]$_[2]";
177 39 my $nq = $self->safe_quant($q);
178 39 $self->add(")$nq",")$q");
179 39 $self->pop_state;
180 39 return $self;
181 }
182  
183 package Regexp::Genex::alt;
184 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
185 1 my $self = $_[0]->SUPER::new(@_[1..$#_]);
186 1 $self->add('|','|');
187 1 return $self;
188 }
189  
190 package Regexp::Genex::backref;
191 # perl -W -MRegexp::Genex -e 'Regexp::Genex::rx(qr/(.)=\1{0,2}/)'
192 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
193 1 my $self = $_[0]->SUPER::new(@_[1..$#_]);
194 1 my $var = $_[1];
195 1 my $q = $self->quant;
196 1 my $nq = $self->safe_quant($q);
197 1 my $text = $self->text;
198  
199 # the offsets are to the target string but we take that section of $^R
200 1 $self->add(
201 '(?: .{1} (?{ $^R.substr($^R,$-[1],$+[1]-$-[1]) }) )'.$nq, $text.$q
202 );
203 1 return $self;
204 }
205  
206 package Regexp::Genex::text;
207 41 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
208 41 my $self = $_[0]->SUPER::new(@_[1..$#_]);
209 41 my $text = $self->text;
210 41 my $q = $self->quant;
211 41 my $nq = $self->safe_quant($q);
212 41 my $case_mod = $self->case_mod;
213  
214 41 my $len = length($text);
215 41 $text = Regexp::Genex::Element::escape($text);
216 41 $self->add("(?: .{$len} (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
217 41 return $self;
218 }
219  
220 package Regexp::Genex::oct;
221 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
222 1 my $self = $_[0]->SUPER::new(@_[1..$#_]);
223 1 my $text = $self->text;
224 1 my $q = $self->quant;
225 1 my $nq = $self->safe_quant($q);
226 1 my $case_mod = $self->case_mod;
227  
228 1 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
229 1 return $self;
230 }
231  
232 package Regexp::Genex::hex;
233 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
234 1 my $self = $_[0]->SUPER::new(@_[1..$#_]);
235 1 my $text = $self->text;
236 1 my $q = $self->quant;
237 1 my $nq = $self->safe_quant($q);
238 1 my $case_mod = $self->case_mod;
239  
240 1 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
241 1 return $self;
242 }
243  
244 package Regexp::Genex::utf8hex;
245 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
246 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
247 0 my $text = $self->text;
248 0 my $q = $self->quant;
249 0 my $nq = $self->safe_quant($q);
250 0 my $case_mod = $self->case_mod;
251  
252 0 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
253 0 return $self;
254 }
255  
256 package Regexp::Genex::ctrl;
257 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
258 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
259 0 my $text = $self->text;
260 0 my $q = $self->quant;
261 0 my $nq = $self->safe_quant($q);
262 0 my $case_mod = $self->case_mod;
263  
264 0 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
265 0 return $self;
266 }
267  
268 package Regexp::Genex::named;
269 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
270 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
271 0 my $text = $self->text;
272 0 my $q = $self->quant;
273 0 my $nq = $self->safe_quant($q);
274 0 my $case_mod = $self->case_mod;
275  
276 0 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
277 0 return $self;
278 }
279  
280 package Regexp::Genex::Cchar;
281 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
282 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
283 0 my $text = $self->text;
284 0 my $q = $self->quant;
285 0 my $nq = $self->safe_quant($q);
286 0 my $case_mod = $self->case_mod;
287  
288 0 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
289 0 return $self;
290 }
291  
292 package Regexp::Genex::slash;
293 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
294 4 my $self = $_[0]->SUPER::new(@_[1..$#_]);
295 4 my $text = $self->text;
296 4 my $q = $self->quant;
297 4 my $nq = $self->safe_quant($q);
298 4 my $case_mod = $self->case_mod;
299  
300 4 $self->add("(?: . (?{ \$^R.\"$case_mod$text\" }) )$nq", $text.$q);
301 4 return $self;
302 }
303  
304 package Regexp::Genex::any;
305 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
306 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
307 0 my $q = $self->quant;
308 0 my $nq = $self->safe_quant($q);
309  
310 #my ($nl, $n) = ('', 3);
311 #($nl, $n) = (',"\n"', 4) if($self->dot_nl);
312 0 ▶ my ($n, @chars) = ($self->dot_nl)
Branch: 1 branch
BranchTrueFalseTotal
$self->dot_nl ? : 0 0 0
313 ? $self->class_chars(qr/./s)
314 : $self->class_chars(qr/./);
315  
316 0 local($") = ",";
317 0 $self->add("(?: . (?{ \$^R.(@chars)[rand $n] }) )$nq", ".$q");
318 #$self->add("(?: . (?{ \$^R.('.','x','X'$nl)[rand $n] }) )$nq",".$q");
319 0 return $self;
320 }
321  
322 package Regexp::Genex::macro;
323 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
324 0 my $self = $_[0]->SUPER::new(@_[1..$#_]);
325 0 my $text = $self->text;
326 0 my $q = $self->quant;
327 0 my $nq = $self->safe_quant($q);
328  
329 # \d \D \w \W \s \S
330 0 my ($n, @chars) = $self->class_chars(qr/$text/);
331  
332 0 local($") = ",";
333 0 $self->add("(?: . (?{ \$^R.(@chars)[rand $n] }) )$nq", "$text$q");
334 0 return $self;
335 }
336  
337 package Regexp::Genex::class;
338 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
339 5 my $self = $_[0]->SUPER::new(@_[1..$#_]);
340 5 my $text = $self->text;
341 5 my $q = $self->quant;
342 5 my $nq = $self->safe_quant($q);
343  
344 # [^dfads]
345 5 my ($n, @chars) = $self->class_chars(qr/$text/);
346  
347 5 local($") = ",";
348 5 $self->add("(?: . (?{ \$^R.(@chars)[rand $n] }) )$nq", "$text$q");
349 5 return $self;
350 }
351  
352 # TODO
353 package Regexp::Genex::anchor;
354 # $ is a lookahead \n|\z
355 # \A \z \Z ^ $ \G
356 # ^ $ are /s sensitive (multiline)
357 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
358 0 Carp::croak("Genex: Anchors not implemented ^ \$ \\A \\Z \\z \\G\n");
359 }
360 package Regexp::Genex::lookahead;
361 # could run look ahead code at the end and check the output...
362 # might be no match possible with random string selections
363 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
364 0 Carp::croak("Genex: Look-ahead not implemented (?=...) (?!...)\n");
365 }
366 package Regexp::Genex::lookbehind;
367 # can look behind! match against the string we have made or fail
368 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
369 0 Carp::croak("Genex: Look-behind not implemented (?<=...) (?<!...)\n");
370 }
371  
372 package Regexp::Genex::cond;
373 # probably ok, except for the close complications
374 # (?(1) ... ) should test our $1
375 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
376 0 Carp::croak("Genex: Cut not implemented (?(...)...|...)\n");
377 }
378  
379 package Regexp::Genex::cut;
380 # probably ok, except for the close complications
381 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
382 0 Carp::croak("Genex: Cut not implemented (?>...)\n");
383 }
384  
385 package Regexp::Genex::code;
386 # trashes $^R (stash it somewhere else locally)
387 # could use condition to avoid $^R trashing (?( (?{...}) ) )
388 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
389 0 Carp::croak("Genex: Code assertion not implemented (?{...})\n");
390 }
391  
392 package Regexp::Genex::later; # (??{})
393 # probably ok, except for the close complications
394 # may need original modifier state (esp. /x)
395 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
396 0 Carp::croak("Genex: Delayed regex not implemented (??{...})\n");
397 }
398  
399 #sub new {
400 # Carp::carp("Delayed regex not handled (??{...})");
401 # my $self = $_[0]->SUPER::new(@_[1..$#_]);
402 # my $text = $self->text;
403 # my $q = $self->quant;
404 # my $nq = $self->safe_quant($q);
405 #
406 # # HACK needs no_close handling in close->new
407 # push @stack, {
408 # anycase => $self->anycase, dot_nl => $self->dot_nl,
409 # q => $stack[$top]{q}, nq => $stack[$top]{nq},
410 # no_close => 1,
411 # };
412 #
413 # $in .= ' ';
414 #
415 # $self->add($text.$nq, $text.$q);
416 # return $self;
417 #}
418  
419 package Regexp::Genex;
420 1 ▶use YAPE::Regex 'Regexp::Genex';
Subroutine BEGIN: called CC=1 SCAR=0.0
421  
422 1 require Exporter;
423 1 our @ISA = qw(Exporter YAPE::Regex);
424 1 our @EXPORT_OK = qw(strings strings_rx generator generator_rx);
425 1 our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
426  
427 1 our $DEFAULT_LEN = 10;
428  
429 35 ▶sub strings {
Subroutine strings: called CC=2 SCAR=7.1
Pod documented
430 35 my ($rx_arg, $len) = @_;
431 35 my $rx_str = strings_rx($rx_arg);
432  
433 35 ▶ $len ||= $DEFAULT_LEN;
Condition33%1/3
$len ||= $Regexp::Genex::DEFAULT_LEN
l!l&&r!l&&!r
0350
MC/DC0%0/2
$len ||= $Regexp::Genex::DEFAULT_LEN
$len $Regexp::Genex::DEFAULT_LEN
Truth table33%1/3
A ||= B
A= $lenB= $Regexp::Genex::DEFAULT_LEN
ABresult
1X1
011
000
434  
435 1 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
436 #eval 'use re "debug"';
437 35 ("a"x$len) =~ qr/$rx/x;
438  
439 35 return @_;
440 }
441  
442 38 ▶sub _main_rx {
Subroutine _main_rx: called CC=2 SCAR=6.9
443 38 my $in_rx = shift;
444  
445 38 $rx = "";
446 38 my $orig_rx = Regexp::Genex::Element::escape($in_rx);
447 38 Regexp::Genex::Element->add('', "Orignal: $orig_rx");
448  
449 # The ^ means the target length can limit output
450 38 Regexp::Genex::Element->add(
451 '^(?> (?{ @_ = (); "" }) )', 'Initialize $^R & @_');
452 38 $in = ' ';
453  
454 38 my $yape = Regexp::Genex->new($in_rx);
455 38 ▶ $yape->parse; die $yape->error if $yape->error;
Branch: 1 branch
BranchTrueFalseTotal
if $yape->error 0 38 38
456
457 38 $in = '';
458 # left in $rx
459 }
460  
461 36 ▶sub strings_rx {
Subroutine strings_rx: called CC=1 SCAR=0.0
Pod documented
462 36 my $in_rx = shift;
463  
464 36 _main_rx($in_rx);
465
466 36 Regexp::Genex::Element->add(
467 '(?{ push @_, $^R }) (?!)', 'Save & backtrack');
468  
469 36 return $rx;
470 }
471  
472 2 ▶sub generator_rx {
Subroutine generator_rx: called CC=1 SCAR=0.0
Pod documented
473 2 my $in_rx = shift;
474  
475 2 _main_rx($in_rx);
476  
477 2 Regexp::Genex::Element->add(
478 '(?(?{ @_ = $^R if $c++ == $n; }) (?=) | (?!) )',
479 'Replay up to $n then stop');
480  
481 2 return $rx;
482 }
483  
484 # perl -MRegexp::Genex=:all -le '$i = generator(qr/ab*?/); print $i->() for 1..4; print $i->(1)'
485 1 ▶sub generator {
Subroutine generator: called CC=2 SCAR=7.0
Pod documented
486 1 my ($rx_arg, $len) = @_;
487 1 ▶ $len ||= $DEFAULT_LEN;
Condition33%1/3
$len ||= $Regexp::Genex::DEFAULT_LEN
l!l&&r!l&&!r
010
MC/DC0%0/2
$len ||= $Regexp::Genex::DEFAULT_LEN
$len $Regexp::Genex::DEFAULT_LEN
Truth table33%1/3
A ||= B
A= $lenB= $Regexp::Genex::DEFAULT_LEN
ABresult
1X1
011
000
488 1 my $rx_str = generator_rx($rx_arg);
489  
490 # These vars are captured both by the closure and the regex
491 1 my $n = 0;
492 1 my $c;
493  
494 1 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
495 #eval "use re 'debug'";
496 1 my $qr = qr/$rx_str/x;
497  
498 5 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
499 5 ▶ $n = shift if defined $_[0]; # reset's with argument
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 1 4 5
500  
501 5 $c = 0; # reset found counter
502 5 ('a'x$len) =~ $qr;
503 5 $n++; # track next to show
504 5 return $_[0];
505 1 };
506 }
507  
508 1 1;
509 __END__
↑ Summary