« lib/WWW/Hetzner/CLI/Cmd/PrimaryIp/Cmd/Describe.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/Network/Cmd/Describe.pm »
| 1 | package WWW::Hetzner::Cloud::Costs; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Current running cost of a Hetzner Cloud project | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 60 | our $VERSION = '0.102'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 60 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 60 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 60 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 60 | has client => ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 14 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | # Hours after which hourly billing reaches the monthly cap; the ratio between | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # price_monthly and price_hourly for every item that has both. | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 60 | our $HOURS_PER_MONTH = 624; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 13 | ▶ | sub calculate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calculate: called CC=27 SCAR=33.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | ▶ | my $price = $opts{price} // 'gross'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"price"} // "gross"
MC/DC100%1/1
$opts{"price"} // "gross"
$opts{"price"}
Truth table100%2/2
A
A= $opts{"price"}
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 13 | ▶ | croak "price must be 'net' or 'gross', not '$price'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$price eq "net" or $price eq "gross"
MC/DC100%2/2
$price eq "net" or $price eq "gross"
$price eq "net"
$price eq "gross"
Truth table100%3/3
A or B
A= $price eq "net"B= $price eq "gross"
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | unless $price eq 'net' || $price eq 'gross'; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 12 | my %filter; | |||||||||||||||||||||||||||||||||||||||||
| 30 | $filter{label_selector} = $opts{label_selector} | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | ▶ | if defined $opts{label_selector} && length $opts{label_selector}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $opts{"label_selector"} and length $opts{"label_selector"}
MC/DC50%1/2
defined $opts{"label_selector"} and length $opts{"label_selector"}
defined $opts{"label_selector"}
length $opts{"label_selector"}
Truth table66%2/3
A and B
A= defined $opts{"label_selector"}B= length $opts{"label_selector"}
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 12 | my $client = $self->client; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 12 | my $pricing = $client->pricing->get; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 204 | ▶ | my $amount = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 204 | my ($p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 204 | ▶ | return undef unless ref $p eq 'HASH' && defined $p->{$price}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $p eq "HASH" and defined $p->{$price}
MC/DC50%1/2
ref $p eq "HASH" and defined $p->{$price}
ref $p eq "HASH"
defined $p->{$price}
Truth table66%2/3
A and B
A= ref $p eq "HASH"B= defined $p->{$price}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 180 | return 0 + $p->{$price}; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 48 | ▶ | my $by_location = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 48 | my ($entries, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 48 | my %index; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 48 | ▶ | for my $entry (@{ $entries // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$entries // []
MC/DC0%0/1
$entries // []
$entries
Truth table50%1/2
A
A= $entries
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 72 | ▶ | for my $p (@{ $entry->{prices} // [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$entry->{"prices"} // []
MC/DC0%0/1
$entry->{"prices"} // []
$entry->{"prices"}
Truth table50%1/2
A
A= $entry->{"prices"}
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | $index{ $entry->{$key} }{ $p->{location} } = { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | hourly => $amount->($p->{price_hourly}), | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 96 | monthly => $amount->($p->{price_monthly}), | |||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 48 | return \%index; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | my $server_prices = $by_location->($pricing->server_types, 'name'); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | my $lb_prices = $by_location->($pricing->load_balancer_types, 'name'); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | my $pip_prices = $by_location->($pricing->primary_ips, 'type'); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | my $fip_prices = $by_location->($pricing->floating_ips, 'type'); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 12 | ▶ | my $volume_gb = $amount->(($pricing->volume // {})->{price_per_gb_month}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pricing->volume // {}
MC/DC0%0/1
$pricing->volume // {}
$pricing->volume
Truth table50%1/2
A
A= $pricing->volume
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | ▶ | my $backup_pct = ($pricing->server_backup // {})->{percentage}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$pricing->server_backup // {}
MC/DC0%0/1
$pricing->server_backup // {}
$pricing->server_backup
Truth table50%1/2
A
A= $pricing->server_backup
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 12 | my (@rows, @warnings); | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 101 | ▶ | my $add = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 101 | my (%row) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 101 | my $p = delete $row{_price}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 101 | ▶ | if (!defined $p || !defined $p->{monthly}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $p && defined $p->{'monthly'}
MC/DC50%1/2
defined $p && defined $p->{'monthly'}
defined $p
defined $p->{'monthly'}
Truth table66%2/3
A && B
A= defined $pB= defined $p->{'monthly'}
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | push @warnings, sprintf "no %s price for %s %s (%s) in %s", | ||||||||||||||||||||||||||||||||||||||||||
| 70 | $price, $row{kind}, $row{name} // $row{id}, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | $row{type} // '-', $row{location} // '-'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition42%3/7
$row{"name"} // $row{"id"}
$row{"type"} // "-"
$row{"location"} // "-"
MC/DC0%0/2
$row{"name"} // $row{"id"}
$row{"name"}
$row{"id"}
MC/DC0%0/1
$row{"type"} // "-"
$row{"type"}
MC/DC0%0/1
$row{"location"} // "-"
$row{"location"}
Truth table33%1/3
A // B
A= $row{"name"}B= $row{"id"}
Truth table50%1/2
A
A= $row{"type"}
Truth table50%1/2
A
A= $row{"location"}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | $row{hourly} = $row{monthly} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 100 | $row{monthly} = _round($p->{monthly}); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 100 | ▶ | if (defined $p->{hourly}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 80 | $row{hourly} = _round($p->{hourly}); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 80 | $row{hourly_derived} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 20 | $row{hourly} = _round($p->{monthly} / $HOURS_PER_MONTH); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 20 | $row{hourly_derived} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 101 | push @rows, \%row; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | for my $s (@{ $client->servers->list_all(%filter) }) { | |||||||||||||||||||||||||||||||||||||||||
| 89 | 31 | my %base = ( | |||||||||||||||||||||||||||||||||||||||||
| 90 | id => $s->id, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | name => $s->name, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | type => $s->server_type, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | location => $s->location, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | status => $s->status, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 31 | my $p = _lookup($server_prices, $base{type}, $base{location}); | |||||||||||||||||||||||||||||||||||||||||
| 97 | 31 | $add->(kind => 'server', %base, _price => $p); | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 31 | ▶ | if (defined $s->backup_window && $p && defined $backup_pct) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $s->backup_window and $p and defined $backup_pct
defined $s->backup_window and $p
MC/DC33%1/3
defined $s->backup_window and $p and defined $backup_pct
defined $s->backup_window
$p
defined $backup_pct
Truth table50%2/4
A and B and C
A= defined $s->backup_windowB= $pC= defined $backup_pct
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | my $f = $backup_pct / 100; | |||||||||||||||||||||||||||||||||||||||||
| 101 | $add->(kind => 'server_backup', %base, _price => { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | monthly => defined $p->{monthly} ? $p->{monthly} * $f : undef, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 10 | ▶ | hourly => defined $p->{hourly} ? $p->{hourly} * $f : undef, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 12 | for my $v (@{ $client->volumes->list_all(%filter) }) { | |||||||||||||||||||||||||||||||||||||||||
| 109 | 10 | ▶ | $add->( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$v->size // 0
$v->size // 0
MC/DC0%0/1
$v->size // 0
$v->size
MC/DC0%0/1
$v->size // 0
$v->size
Truth table50%1/2
A
A= $v->size
Truth table50%1/2
A
A= $v->size
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | kind => 'volume', | ||||||||||||||||||||||||||||||||||||||||||
| 111 | id => $v->id, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | name => $v->name, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | type => ($v->size // 0) . ' GB', | ||||||||||||||||||||||||||||||||||||||||||
| 114 | location => $v->location, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | status => $v->status, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | size => $v->size, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | _price => defined $volume_gb | ||||||||||||||||||||||||||||||||||||||||||
| 118 | ? { monthly => ($v->size // 0) * $volume_gb } : undef, | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 12 | for my $ip (@{ $client->primary_ips->list_all(%filter) }) { | |||||||||||||||||||||||||||||||||||||||||
| 123 | 30 | my $type = $ip->type; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 30 | ▶ | my $p = exists $pip_prices->{$type // ''} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$type // ""
MC/DC0%0/1
$type // ""
$type
Truth table50%1/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | ? _lookup($pip_prices, $type, $ip->location) | ||||||||||||||||||||||||||||||||||||||||||
| 126 | : { hourly => 0, monthly => 0 }; # unpriced type, e.g. ipv6: free | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 30 | ▶ | $add->( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | kind => 'primary_ip', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | id => $ip->id, | ||||||||||||||||||||||||||||||||||||||||||
| 130 | name => $ip->name, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | location => $ip->location, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | status => $ip->is_assigned ? 'assigned' : 'unassigned', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | _price => $p, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 12 | for my $ip (@{ $client->floating_ips->list_all(%filter) }) { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | ▶ | $add->( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | kind => 'floating_ip', | ||||||||||||||||||||||||||||||||||||||||||
| 141 | id => $ip->id, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | name => $ip->name, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | type => $ip->type, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | location => $ip->location, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | status => $ip->is_assigned ? 'assigned' : 'unassigned', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | _price => _lookup($fip_prices, $ip->type, $ip->location), | ||||||||||||||||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 12 | for my $lb (@{ $client->load_balancers->list_all(%filter) }) { | |||||||||||||||||||||||||||||||||||||||||
| 151 | 10 | $add->( | |||||||||||||||||||||||||||||||||||||||||
| 152 | kind => 'load_balancer', | ||||||||||||||||||||||||||||||||||||||||||
| 153 | id => $lb->id, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | name => $lb->name, | ||||||||||||||||||||||||||||||||||||||||||
| 155 | type => $lb->type_name, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | location => $lb->location_name, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | _price => _lookup($lb_prices, $lb->type_name, $lb->location_name), | ||||||||||||||||||||||||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | my ($hourly, $monthly) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | for my $r (@rows) { | |||||||||||||||||||||||||||||||||||||||||
| 163 | 101 | ▶ | next unless defined $r->{monthly}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 100 | $hourly += $r->{hourly}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 100 | $monthly += $r->{monthly}; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | currency => $pricing->currency, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | vat_rate => $pricing->vat_rate, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | price => $price, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | label_selector => $filter{label_selector}, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 12 | hours_per_month => $HOURS_PER_MONTH, | |||||||||||||||||||||||||||||||||||||||||
| 174 | resources => \@rows, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | totals => { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | hourly => _round($hourly), | ||||||||||||||||||||||||||||||||||||||||||
| 177 | monthly => _round($monthly), | ||||||||||||||||||||||||||||||||||||||||||
| 178 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | warnings => \@warnings, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 71 | ▶ | sub _lookup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lookup: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 71 | my ($index, $name, $location) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 71 | ▶ | return undef unless defined $name && defined $location; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and defined $location
MC/DC0%0/2
defined $name and defined $location
defined $name
defined $location
Truth table33%1/3
A and B
A= defined $nameB= defined $location
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 71 | return $index->{$name}{$location}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 224 | ▶ | sub _round { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_round: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 224 | my ($n) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 224 | return 0 + sprintf('%.6f', $n); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 60 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | __END__ | ||||||||||||||||||||||||||||||||||||||||||