line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Base::ModuleBuild::Utils; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
194536
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
158
|
|
4
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
146
|
|
5
|
6
|
|
|
6
|
|
5034
|
use Text::Balanced qw/extract_bracketed extract_delimited extract_multiple/; |
|
6
|
|
|
|
|
76393
|
|
|
6
|
|
|
|
|
464
|
|
6
|
6
|
|
|
6
|
|
1158
|
use parent 'Exporter'; |
|
6
|
|
|
|
|
717
|
|
|
6
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Private utilities |
9
|
|
|
|
|
|
|
our $VERSION = '1.17'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw/find_anchor_targets pattern_has_capture_groups/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub find_anchor_targets { |
14
|
4
|
|
|
4
|
0
|
80
|
my $html = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @tags = extract_multiple( |
17
|
|
|
|
|
|
|
$html, |
18
|
4
|
|
|
350
|
|
42
|
[ sub { extract_bracketed($_[0], '<>') } ], |
|
350
|
|
|
|
|
22640
|
|
19
|
|
|
|
|
|
|
undef, 1 |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
@tags = |
23
|
11
|
|
|
|
|
30
|
map { extract_href($_) } # find related href= |
24
|
4
|
|
|
|
|
981
|
grep { /^
|
|
34
|
|
|
|
|
78
|
|
25
|
|
|
|
|
|
|
@tags; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
33
|
return @tags; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub extract_href { |
31
|
11
|
|
|
11
|
0
|
24
|
my $tag = shift; |
32
|
11
|
100
|
|
|
|
86
|
if($tag =~ /href=(?='|")/gci) { |
|
|
50
|
|
|
|
|
|
33
|
6
|
|
|
|
|
25
|
my $text = scalar extract_delimited( $tag, q{'"} ); |
34
|
6
|
|
|
|
|
643
|
my $delim = substr $text, 0, 1; |
35
|
6
|
|
|
|
|
42
|
$text =~ s/^$delim//; |
36
|
6
|
|
|
|
|
36
|
$text =~ s/$delim$//; |
37
|
6
|
|
|
|
|
24
|
return $text; |
38
|
|
|
|
|
|
|
} elsif ($tag =~ /href=(.*?)(?:\s|\n|>)/i) { |
39
|
5
|
|
|
|
|
23
|
return $1; |
40
|
|
|
|
|
|
|
} else { |
41
|
0
|
|
|
|
|
0
|
return (); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub pattern_has_capture_groups { |
46
|
5
|
|
|
5
|
0
|
5735
|
my $re = shift; |
47
|
5
|
|
|
|
|
171
|
"" =~ /|$re/; |
48
|
5
|
|
|
|
|
45
|
return $#+; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |