| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | package Tie::Scalar::Ratio; | ||||||||||||||||||||||||||||
| 4 | 1 | $Tie::Scalar::Ratio::VERSION = '0.01'; | |||||||||||||||||||||||||||
| 5 | 1 | ▶ | use parent 'Tie::Scalar'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | #ABSTRACT: a scalar which multiplies in value every time it is accessed. | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | sub TIESCALAR { | ||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 10 | 5 | my ($class, $ratio, $value) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | die 'Must provide ratio argument, a number to multiply the scalar value by' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ratio and $ratio =~ /^[\d.]+$/
MC/DC100%2/2
$ratio and $ratio =~ /^[\d.]+$/
$ratio
$ratio =~ /^[\d.]+$/
Truth table100%3/3
A and B
A= $ratioB= $ratio =~ /^[\d.]+$/
| |||||||||||||||||||||||||||||
| 13 | unless $ratio && $ratio =~ /^[\d.]+$/; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | bless { | |||||||||||||||||||||||||||
| 16 | ratio => $ratio, | ||||||||||||||||||||||||||||
| 17 | value => $value, | ||||||||||||||||||||||||||||
| 18 | }, $class; | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 2 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 23 | 2 | $self->{value} = $value; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 11 | ▶ | sub FETCH { | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 27 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||
| 28 | 11 | my $old_value = $self->{value}; | |||||||||||||||||||||||||||
| 29 | 11 | ▶ | $self->{value} *= $self->{ratio} if $self->{value}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 11 | return $old_value; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | 1; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | __END__ | ||||||||||||||||||||||||||||