| 1 | 5 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Example::Exporter; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # Inherit from Exporter::Tiny. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use base 'Exporter::Tiny'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # The list of functions to export by default. | ||||||||||||||||||||||||||||
| 12 | # Be conservative. | ||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||
| 14 | 5 | our @EXPORT = qw( fib ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # The list of functions which are allowed to | ||||||||||||||||||||||||||||
| 17 | # be exported. Be liberal. | ||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||
| 19 | 5 | our @EXPORT_OK = qw( embiggen ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Note that there was no need to list "fib" | ||||||||||||||||||||||||||||
| 22 | # in @EXPORT_OK. It was in @EXPORT, so it's | ||||||||||||||||||||||||||||
| 23 | # implicitly ok. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # This is the definition of the "fib" function | ||||||||||||||||||||||||||||
| 26 | # that we want to export. | ||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||
| 28 | sub fib { | ||||||||||||||||||||||||||||
| 29 | 175 | ▶ | my $n = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
fib: called CC=4 SCAR=14.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 175 | ▶ | (int($n) eq $n) && ($n >= 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
int $n eq $n and $n >= 0
MC/DC0%0/2
int $n eq $n and $n >= 0
int $n eq $n
$n >= 0
Truth table33%1/3
A and B
A= int $n eq $nB= $n >= 0
| |||||||||||||||||||||||||||||
| 32 | or die "Expected natural number as argument; got '$n'"; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 175 | ▶ | return $n if $n < 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 84 | fib($n - 1) + fib($n - 2); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # We won't define a standard embiggen function. | ||||||||||||||||||||||||||||
| 40 | # Instead we will generate one when requested. | ||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||
| 42 | sub _generate_embiggen { | ||||||||||||||||||||||||||||
| 43 | 4 | ▶ | my ($class, $name, $arg, $globals) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_generate_embiggen: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 4 | ▶ | my $embiggen_amount = exists($arg->{amount}) ? $arg->{amount} : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # This is the sub that will be installed into | ||||||||||||||||||||||||||||
| 48 | # the caller's namespace. | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | return sub ($) { | ||||||||||||||||||||||||||||
| 51 | 4 | ▶ | my $n = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 4 | return $n + $embiggen_amount; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 4 | } | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 5 | 1; # Make Perl Happy™ | |||||||||||||||||||||||||||