| 1 | package Regexp::Common::list; | ||||||||||
| 2 | |||||||||||
| 3 | 71 | ▶ | use 5.10.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 71 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 71 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 71 | ▶ | no warnings 'syntax'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 71 | ▶ | use Regexp::Common qw /pattern clean no_defaults/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 71 | our $VERSION = '2024080801'; | |||||||||
| 12 | |||||||||||
| 13 | 8 | ▶ | sub gen_list_pattern { | ||||||||
|
Subroutine
gen_list_pattern: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | 8 | my ($pat, $sep, $lsep) = @_; | |||||||||
| 15 | 8 | ▶ | $lsep = $sep unless defined $lsep; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 8 | return "(?k:(?:(?:$pat)(?:$sep))*(?:$pat)(?k:$lsep)(?:$pat))"; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 71 | my $defpat = '.*?\S'; | |||||||||
| 20 | 71 | my $defsep = '\s*,\s*'; | |||||||||
| 21 | |||||||||||
| 22 | pattern name => ['list', "-pat=$defpat", "-sep=$defsep", '-lastsep'], | ||||||||||
| 23 | 4 | ▶ | create => sub {gen_list_pattern (@{$_[1]}{-pat, -sep, -lastsep})}, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 71 | ; | |||||||||
| 25 | |||||||||||
| 26 | pattern name => ['list', 'conj', '-word=(?:and|or)'], | ||||||||||
| 27 | 3 | ▶ | create => sub {gen_list_pattern($defpat, $defsep, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 3 | '\s*,?\s*'.$_[1]->{-word}.'\s*'); | |||||||||
| 29 | }, | ||||||||||
| 30 | 71 | ; | |||||||||
| 31 | |||||||||||
| 32 | pattern name => ['list', 'and'], | ||||||||||
| 33 | 1 | ▶ | create => sub {gen_list_pattern ($defpat, $defsep, '\s*,?\s*and\s*')}, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 71 | ; | |||||||||
| 35 | |||||||||||
| 36 | pattern name => ['list', 'or'], | ||||||||||
| 37 | 0 | ▶ | create => sub {gen_list_pattern ($defpat, $defsep, '\s*,?\s*or\s*')}, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 71 | ; | |||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 71 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||