| 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
| |||||||||||
| 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__ | ||||||||||