| 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
| |||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$list and $list =~ m(<pre>\[([-0-9,\s]+)\]</pre>)iu
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
| |||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$to > @values and eval "use OEIS::$sequence; 1"
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"
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||