| 1 | package Data::Sah::Filter::perl::Perl::normalize_perl_modname_pm; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.010001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 8 | 1 | our $DATE = '2024-02-16'; # DATE | |
| 9 | 1 | our $DIST = 'Sah-SchemaBundle-Perl'; # DIST | |
| 10 | 1 | our $VERSION = '0.050'; # VERSION | |
| 11 | |||
| 12 | 0 | ▶ | sub meta { |
|
Subroutine
meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 13 | +{ | ||
| 14 | 0 | v => 1, | |
| 15 | summary => 'Normalize perl module name to Foo/Bar.pm form', | ||
| 16 | might_fail => 1, | ||
| 17 | examples => [ | ||
| 18 | {value=>"Foo:Bar", valid=>1, filtered_value=>"Foo/Bar.pm"}, | ||
| 19 | {value=>"Foo::Bar,arg1,arg2", valid=>1, filtered_value=>"Foo/Bar.pm=arg1,arg2"}, | ||
| 20 | ], | ||
| 21 | }; | ||
| 22 | } | ||
| 23 | |||
| 24 | 0 | ▶ | sub filter { |
|
Subroutine
filter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 25 | 0 | my %args = @_; | |
| 26 | |||
| 27 | 0 | my $dt = $args{data_term}; | |
| 28 | |||
| 29 | 0 | my $res = {}; | |
| 30 | |||
| 31 | 0 | $res->{expr_filter} = join( | |
| 32 | "", | ||
| 33 | "do { my \$tmp = $dt; ", | ||
| 34 | "if (ref \$tmp) { [\"Must be a string and not a reference\", \$tmp] } ", | ||
| 35 | "else { ", ( | ||
| 36 | "my \$argssuffix = ''; \$argssuffix = \$1 if \$tmp =~ s/([=,].*)\\z//; \$argssuffix =~ s/\\A,/=/; ", # extract args suffix (=arg1,arg2) first. we allow % in addition to = | ||
| 37 | "my \$versuffix = ''; \$versuffix = \$1 if \$tmp =~ s/(\@[0-9][0-9A-Za-z]*(\\.[0-9A-Za-z_]+)*)\\z//; ", # extract version suffix part first | ||
| 38 | "\$tmp = \$1 if \$tmp =~ m!\\A(\\w+(?:/+\\w+)*)\.pm\\z!; ", | ||
| 39 | "\$tmp =~ s!::*|/+|\\.+|-!::!g; ", | ||
| 40 | "\$tmp =~ s!::!/!g; ", | ||
| 41 | "[undef, \"\$tmp.pm\" . \$versuffix . \$argssuffix]; "), | ||
| 42 | "} }", | ||
| 43 | ); | ||
| 44 | |||
| 45 | 0 | $res; | |
| 46 | } | ||
| 47 | |||
| 48 | 1 | 1; | |
| 49 | # ABSTRACT: | ||
| 50 | |||
| 51 | __END__ | ||