Common/URI.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 95.3% 41 / 43 CC 1 SCAR 0.0
CC
1
Cov
97%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Common/list.pm ↑ Summary Common/CC.pm »
1 package Regexp::Common::URI;
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 Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 71 our @ISA = qw /Exporter/;
12 71 our @EXPORT_OK = qw /register_uri/;
13  
14 71 ▶use Regexp::Common qw /pattern clean no_defaults/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 71 our $VERSION = '2024080801';
17  
18 # Use 'require' here, not 'use', so we delay running them after we are compiled.
19 # We also do it using an 'eval'; this saves us from have repeated similar
20 # lines. The eval is further explained in 'perldoc -f require'.
21 71 my @uris = qw /fax file ftp gopher http pop prospero news tel telnet tv wais/;
22 71 foreach my $uri (@uris) {
23 852 eval "require Regexp::Common::URI::$uri";
24 852 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 852 852
25 }
26  
27 71 my %uris;
28  
29 923 ▶sub register_uri {
Subroutine register_uri: called CC=1 SCAR=0.0
Pod undocumented
30 923 my ($scheme, $uri) = @_;
31 923 $uris {$scheme} = $uri;
32 }
33  
34 pattern name => [qw (URI)],
35 1 ▶ create => sub {my $uri = join '|' => values %uris;
Subroutine __ANON__: called CC=1 SCAR=0.0
36 1 $uri =~ s/\(\?k:/(?:/g;
37 1 "(?k:$uri)";
38 },
39 71 ;
40  
41 71 1;
42  
43 __END__
« Common/list.pm ↑ Summary Common/CC.pm »