OEIS.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 81.8% 54 / 66 CC 8 SCAR 16.7
CC
8
Cov
85%
oeis
9.7
BEGIN
1.0
BEGIN
1.0
CRAP 5.3
↑ Summary OEIS/A000045.pm »
1 package OEIS;
2  
3 4 ▶use 5.032;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶no warnings 'syntax';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 our $VERSION = '2021041201';
13  
14 4 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 our @ISA = qw [Exporter];
16 4 our @EXPORT = qw [oeis];
17  
18 4 my $URL = "https://oeis.org/%s/list";
19  
20 3 ▶sub oeis ($sequence, $to = -1) {
Subroutine oeis: called CC=8 SCAR=22.7
Pod undocumented
21 3 ▶ $sequence = sprintf "A%06d" => $sequence if $sequence =~ /^[0-9]/;
Branch: 1 branch
BranchTrueFalseTotal
if $sequence =~ /^[0-9]/u 0 3 3
22 3 my $list = get sprintf $URL => $sequence;
23 3 my @values;
24  
25 #
26 # Extract the numbers from the <PRE> section
27 #
28 3 ▶ if ($list && $list =~ m {<pre>\[([-0-9,\s]+)\]</pre>}i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list and $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu) 0 3 3
Condition33%1/3
$list and $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu
!ll&&!rl&&r
300
MC/DC0%0/2
$list and $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu
$list $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu
Truth table33%1/3
A and B
A= $listB= $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu
ABresult
0X0
100
111
29 0 @values = split /[,\s]+/ => $1;
30 }
31 #
32 # If we want more than we can fetch in the list, we see
33 # if we have a module generating them. If so, we use that
34 # module to fill out the rest.
35 #
36 3 ▶ if ($to > @values && eval "use OEIS::$sequence; 1") {
Subroutine BEGIN: called CC=1 SCAR=0.1
Branch: 2 branches
BranchTrueFalseTotal
if ($to > @values and eval "use OEIS::$sequence; 1") { } 1 2 3
elsif (0 <= $to) { } 0 2 2
Condition66%2/3
$to > @values and eval "use OEIS::$sequence; 1"
!ll&&!rl&&r
201
MC/DC50%1/2
$to > @values and eval "use OEIS::$sequence; 1"
$to > @values eval "use OEIS::$sequence; 1"
Truth table66%2/3
A and B
A= $to > @valuesB= eval "use OEIS::$sequence; 1"
ABresult
0X0
100
111
37 1 @values = "OEIS::$sequence" -> new -> init (\@values) -> oeis ($to);
38 }
39 elsif (0 <= $to) {
40 0 splice @values, $to;
41 }
42 3 return @values;
43 }
44  
45  
46 4 1;
47  
48 __END__
↑ Summary OEIS/A000045.pm »