| 1 | package Data::SImeasures; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use base 'Error::Helper'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | Data::SImeasures - The checks if something is a SI measure or not. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | Version 0.0.0 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our $VERSION = '0.0.0'; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | use Data::SImeasures; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | my $sim = Data::SImeasures->new; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | It is worth noting that some measures are present more than | ||||||||||||||||||||||||||||||||||||||||||
| 29 | once as that is more than one common form. These are listed | ||||||||||||||||||||||||||||||||||||||||||
| 30 | below. | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | amp | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ampere | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | meter | ||||||||||||||||||||||||||||||||||||||||||
| 36 | metre | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | Celsius | ||||||||||||||||||||||||||||||||||||||||||
| 39 | degree Celsius | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | This module does have issues dealing with ohm and Celsius as | ||||||||||||||||||||||||||||||||||||||||||
| 42 | when it comes to the symbol as depending on the source, it | ||||||||||||||||||||||||||||||||||||||||||
| 43 | may be represented differently. This will be fixed eventually. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | This initilizes the object. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | my $sim=Data::SImeasures->new; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub new{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $self={ | |||||||||||||||||||||||||||||||||||||||||
| 58 | perror=>undef, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | error=>undef, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | errorString=>'', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | bless $self; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | $self->{measures}={ | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | 'amp'=>'A', | |||||||||||||||||||||||||||||||||||||||||
| 66 | 'ampere'=>'A', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 'metre'=>'m', | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 'meter'=>'m', | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 'gram'=>'g', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 'second'=>'s', | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 'kelvin'=>'K', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 'mole'=>'mol', | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 'candela'=>'cd', | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 'hertz'=>'Hz', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 'radian'=>'rad', | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 'steradian'=>'sr', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'newton'=>'N', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 'pascal'=>'Pa', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 'joule'=>'J', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 'watt'=>'W', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 'coulomb'=>'C', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 'volt'=>'V', | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 'farad'=>'F', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 'ohm'=>'ERROR', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 'siemens'=>'S', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 'weber'=>'Wb', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 'tesla'=>'T', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 'henry'=>'H', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 'degree Celsius'=>'ERROR', | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 'Celsius'=>'ERROR', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 'lumen'=>'lm', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 'lux'=>'lx', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 'becquere'=>'Bq', | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 'gray'=>'Gy', | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 'sievert'=>'Sv', | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 'katal'=>'kat', | ||||||||||||||||||||||||||||||||||||||||||
| 97 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 getSymbol | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | This returns the symbol for the specified measure. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | If if it ohm or Celsius, undef is returned. | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | my $symbol=$self->getSymbol( $symbol ); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | if ( $sim->error ){ | ||||||||||||||||||||||||||||||||||||||||||
| 110 | warn('Failed to match the specified measure'); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 112 | if ( ! defined( $symbol ) ){ | ||||||||||||||||||||||||||||||||||||||||||
| 113 | warn( $measure.' is does not have a supported symbol' ); | ||||||||||||||||||||||||||||||||||||||||||
| 114 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 115 | print "The symbol for ".$measure." is ".$symbol."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub getSymbol{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getSymbol: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $self=$_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $measure=$_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ( ! $self->errorblank ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $self->warnString('Failed to blank the previous error'); | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( ! defined( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $self->{error}=1; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->{errorString}='No measure specified'; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( ! $self->match( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->{error}=2; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->{errorString}=''; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $symbol=$self->{measures}{$measure}; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( $symbol eq 'ERROR' ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return $symbol; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | =head2 match | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | This matches measures. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | This only matches the name, not the symbol. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | If ends in an s, plural, and does not match | ||||||||||||||||||||||||||||||||||||||||||
| 158 | siemens or Celsius, the end s is removed. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | '1' is returned on it being matched and '0' | ||||||||||||||||||||||||||||||||||||||||||
| 161 | if it is not. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | As long as an measure is defined, it wont error. | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | if ( $sim->match( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||||
| 166 | print "It is a valid measure.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub match{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self=$_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $measure=$_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ( ! $self->errorblank ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->warnString('Failed to blank the previous error'); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( ! defined( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->{error}=1; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{errorString}='No measure specified'; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | #remove the end S if it is plural | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$measure =~ /s$/ and not $measure =~ /siemens$/ and not $measure =~ /Celsius$/
$measure =~ /s$/ and not $measure =~ /siemens$/
MC/DC0%0/3
$measure =~ /s$/ and not $measure =~ /siemens$/ and not $measure =~ /Celsius$/
$measure =~ /s$/
not $measure =~ /siemens$/
not $measure =~ /Celsius$/
Truth table0%0/4
A and not(B) and not(C)
A= $measure =~ /s$/B= not $measure =~ /siemens$/C= not $measure =~ /Celsius$/
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | ( $measure=~/s$/ ) && | ||||||||||||||||||||||||||||||||||||||||||
| 189 | ( $measure!~/siemens$/ ) && | ||||||||||||||||||||||||||||||||||||||||||
| 190 | ( $measure!~/Celsius$/ ) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | ){ | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $measure=~s/s$//; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ( defined( $self->{measures}{$measure} ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =head2 matchAll | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | This matches either the symbol or the name of the measure. | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | if ( $sim->matchAll( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||||
| 207 | print "It is a valid measure.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub matchAll{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matchAll: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $self=$_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $measure=$_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ( ! $self->errorblank ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->warnString('Failed to blank the previous error'); | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( ! defined( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{error}=1; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $self->{errorString}='No symbol specified'; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ( $self->match( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ( $self->matchSymbol( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =head2 matchSymbol | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | This matches measure symbols. | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | '1' is returned on it being matched and '0' | ||||||||||||||||||||||||||||||||||||||||||
| 243 | if it is not. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | As long as an measure is defined, it wont error. | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | This currently does not match ohm or Celsius given | ||||||||||||||||||||||||||||||||||||||||||
| 248 | how problematic matching can be. This is planned | ||||||||||||||||||||||||||||||||||||||||||
| 249 | to be fixed in later versions. | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | if ( $sim->matchSymbol( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||||
| 252 | print "It is a valid measure.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub matchSymbol{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
matchSymbol: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $self=$_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $measure=$_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( ! $self->errorblank ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->warnString('Failed to blank the previous error'); | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ( ! defined( $measure ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->{error}=1; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $self->{errorString}='No symbol specified'; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->warn; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my @keys=keys(%{$self->{keys}}); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $int=0; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | while( defined( $keys[$int] ) ){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"measures"}{$keys[$int]} ne "ERROR" and $self->{"measures"}{$keys[$int]} eq $measure
MC/DC0%0/2
$self->{"measures"}{$keys[$int]} ne "ERROR" and $self->{"measures"}{$keys[$int]} eq $measure
$self->{"measures"}{$keys[$int]} ne "ERROR"
$self->{"measures"}{$keys[$int]} eq $measure
Truth table0%0/3
A and B
A= $self->{"measures"}{$keys[$int]} ne "ERROR"B= $self->{"measures"}{$keys[$int]} eq $measure
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | ( $self->{measures}{ $keys[$int] } ne 'ERROR' ) && | ||||||||||||||||||||||||||||||||||||||||||
| 277 | ( $self->{measures}{ $keys[$int] } eq $measure ) | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ){ | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $int++; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =head1 ERROR CODES | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | This module is a Error::Helper ojbect so errors can be checked for | ||||||||||||||||||||||||||||||||||||||||||
| 291 | in the usual fashion. | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | =head2 1 | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | No measure specified. | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Please report any bugs or feature requests to C<bug-data-simeasures at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||||||||||||
| 304 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-SImeasures>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||||||||||||
| 305 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | perldoc Data::SImeasures | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data-SImeasures> | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | L<http://annocpan.org/dist/Data-SImeasures> | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | L<http://cpanratings.perl.org/d/Data-SImeasures> | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | L<http://search.cpan.org/dist/Data-SImeasures/> | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | Copyright 2012 Zane C. Bowers-Hadley. | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 348 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||||||||||||
| 349 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | 1; # End of Data::SImeasures | |||||||||||||||||||||||||||||||||||||||||