| 1 | package Bio::Phylo::Util::CONSTANT; | ||||||||||||||||||||||||||||
| 2 | 57 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 57 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 57 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 57 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 57 | ▶ | use Bio::Phylo::Util::Exceptions 'throw'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 57 | ▶ | use Bio::Phylo::Util::CONSTANT::Int; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 57 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 57 | our ( @EXPORT_OK, %EXPORT_TAGS ); | |||||||||||||||||||||||||||
| 11 | 57 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 12 | _NONE_ | ||||||||||||||||||||||||||||
| 13 | _NODE_ | ||||||||||||||||||||||||||||
| 14 | _TREE_ | ||||||||||||||||||||||||||||
| 15 | _FOREST_ | ||||||||||||||||||||||||||||
| 16 | _TAXON_ | ||||||||||||||||||||||||||||
| 17 | _TAXA_ | ||||||||||||||||||||||||||||
| 18 | _CHAR_ | ||||||||||||||||||||||||||||
| 19 | _DATUM_ | ||||||||||||||||||||||||||||
| 20 | _MATRIX_ | ||||||||||||||||||||||||||||
| 21 | _MATRICES_ | ||||||||||||||||||||||||||||
| 22 | _SEQUENCE_ | ||||||||||||||||||||||||||||
| 23 | _ALIGNMENT_ | ||||||||||||||||||||||||||||
| 24 | _CHARSTATE_ | ||||||||||||||||||||||||||||
| 25 | _CHARSTATESEQ_ | ||||||||||||||||||||||||||||
| 26 | _MATRIXROW_ | ||||||||||||||||||||||||||||
| 27 | _PROJECT_ | ||||||||||||||||||||||||||||
| 28 | _ANNOTATION_ | ||||||||||||||||||||||||||||
| 29 | _DICTIONARY_ | ||||||||||||||||||||||||||||
| 30 | _DOMCREATOR_ | ||||||||||||||||||||||||||||
| 31 | _META_ | ||||||||||||||||||||||||||||
| 32 | _DESCRIPTION_ | ||||||||||||||||||||||||||||
| 33 | _RESOURCE_ | ||||||||||||||||||||||||||||
| 34 | _HTTP_SC_SEE_ALSO_ | ||||||||||||||||||||||||||||
| 35 | _DOCUMENT_ | ||||||||||||||||||||||||||||
| 36 | _ELEMENT_ | ||||||||||||||||||||||||||||
| 37 | _CHARACTERS_ | ||||||||||||||||||||||||||||
| 38 | _CHARACTER_ | ||||||||||||||||||||||||||||
| 39 | _SET_ | ||||||||||||||||||||||||||||
| 40 | _MODEL_ | ||||||||||||||||||||||||||||
| 41 | _OPERATION_ | ||||||||||||||||||||||||||||
| 42 | _DATATYPE_ | ||||||||||||||||||||||||||||
| 43 | looks_like_number | ||||||||||||||||||||||||||||
| 44 | looks_like_object | ||||||||||||||||||||||||||||
| 45 | looks_like_hash | ||||||||||||||||||||||||||||
| 46 | looks_like_class | ||||||||||||||||||||||||||||
| 47 | looks_like_instance | ||||||||||||||||||||||||||||
| 48 | looks_like_implementor | ||||||||||||||||||||||||||||
| 49 | _NS_OWL_ | ||||||||||||||||||||||||||||
| 50 | _NS_DC_ | ||||||||||||||||||||||||||||
| 51 | _NS_DCTERMS_ | ||||||||||||||||||||||||||||
| 52 | _NS_NEXML_ | ||||||||||||||||||||||||||||
| 53 | _NS_RDF_ | ||||||||||||||||||||||||||||
| 54 | _NS_RDFS_ | ||||||||||||||||||||||||||||
| 55 | _NS_XSI_ | ||||||||||||||||||||||||||||
| 56 | _NS_XSD_ | ||||||||||||||||||||||||||||
| 57 | _NS_XML_ | ||||||||||||||||||||||||||||
| 58 | _NS_TOL_ | ||||||||||||||||||||||||||||
| 59 | _NS_CDAO_ | ||||||||||||||||||||||||||||
| 60 | _NS_BIOPHYLO_ | ||||||||||||||||||||||||||||
| 61 | _NS_SKOS_ | ||||||||||||||||||||||||||||
| 62 | _NEXML_VERSION_ | ||||||||||||||||||||||||||||
| 63 | _PI_ | ||||||||||||||||||||||||||||
| 64 | _NS_PHYLOXML_ | ||||||||||||||||||||||||||||
| 65 | _NS_TB2PURL_ | ||||||||||||||||||||||||||||
| 66 | _NS_TNRS_ | ||||||||||||||||||||||||||||
| 67 | _NS_FIGTREE_ | ||||||||||||||||||||||||||||
| 68 | _NS_PHYLOMAP_ | ||||||||||||||||||||||||||||
| 69 | _NS_BIOVEL_ | ||||||||||||||||||||||||||||
| 70 | _NS_NHX_ | ||||||||||||||||||||||||||||
| 71 | _NS_DWC_ | ||||||||||||||||||||||||||||
| 72 | _NS_GBIF_ | ||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||
| 74 | 57 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 75 | 'all' => [@EXPORT_OK], | ||||||||||||||||||||||||||||
| 76 | 'objecttypes' => [ | ||||||||||||||||||||||||||||
| 77 | qw( | ||||||||||||||||||||||||||||
| 78 | _NONE_ | ||||||||||||||||||||||||||||
| 79 | _NODE_ | ||||||||||||||||||||||||||||
| 80 | _TREE_ | ||||||||||||||||||||||||||||
| 81 | _FOREST_ | ||||||||||||||||||||||||||||
| 82 | _TAXON_ | ||||||||||||||||||||||||||||
| 83 | _TAXA_ | ||||||||||||||||||||||||||||
| 84 | _CHAR_ | ||||||||||||||||||||||||||||
| 85 | _DATUM_ | ||||||||||||||||||||||||||||
| 86 | _MATRIX_ | ||||||||||||||||||||||||||||
| 87 | _MATRICES_ | ||||||||||||||||||||||||||||
| 88 | _SEQUENCE_ | ||||||||||||||||||||||||||||
| 89 | _ALIGNMENT_ | ||||||||||||||||||||||||||||
| 90 | _CHARSTATE_ | ||||||||||||||||||||||||||||
| 91 | _CHARSTATESEQ_ | ||||||||||||||||||||||||||||
| 92 | _MATRIXROW_ | ||||||||||||||||||||||||||||
| 93 | _PROJECT_ | ||||||||||||||||||||||||||||
| 94 | _ANNOTATION_ | ||||||||||||||||||||||||||||
| 95 | _DICTIONARY_ | ||||||||||||||||||||||||||||
| 96 | _DOMCREATOR_ | ||||||||||||||||||||||||||||
| 97 | _META_ | ||||||||||||||||||||||||||||
| 98 | _DESCRIPTION_ | ||||||||||||||||||||||||||||
| 99 | _RESOURCE_ | ||||||||||||||||||||||||||||
| 100 | _HTTP_SC_SEE_ALSO_ | ||||||||||||||||||||||||||||
| 101 | _DOCUMENT_ | ||||||||||||||||||||||||||||
| 102 | _ELEMENT_ | ||||||||||||||||||||||||||||
| 103 | _CHARACTERS_ | ||||||||||||||||||||||||||||
| 104 | _CHARACTER_ | ||||||||||||||||||||||||||||
| 105 | _SET_ | ||||||||||||||||||||||||||||
| 106 | _MODEL_ | ||||||||||||||||||||||||||||
| 107 | _OPERATION_ | ||||||||||||||||||||||||||||
| 108 | _DATATYPE_ | ||||||||||||||||||||||||||||
| 109 | ) | ||||||||||||||||||||||||||||
| 110 | ], | ||||||||||||||||||||||||||||
| 111 | 'functions' => [ | ||||||||||||||||||||||||||||
| 112 | qw( | ||||||||||||||||||||||||||||
| 113 | looks_like_number | ||||||||||||||||||||||||||||
| 114 | looks_like_object | ||||||||||||||||||||||||||||
| 115 | looks_like_hash | ||||||||||||||||||||||||||||
| 116 | looks_like_class | ||||||||||||||||||||||||||||
| 117 | looks_like_instance | ||||||||||||||||||||||||||||
| 118 | looks_like_implementor | ||||||||||||||||||||||||||||
| 119 | ) | ||||||||||||||||||||||||||||
| 120 | ], | ||||||||||||||||||||||||||||
| 121 | 'namespaces' => [ | ||||||||||||||||||||||||||||
| 122 | qw( | ||||||||||||||||||||||||||||
| 123 | _NS_OWL_ | ||||||||||||||||||||||||||||
| 124 | _NS_DC_ | ||||||||||||||||||||||||||||
| 125 | _NS_DCTERMS_ | ||||||||||||||||||||||||||||
| 126 | _NS_NEXML_ | ||||||||||||||||||||||||||||
| 127 | _NS_RDF_ | ||||||||||||||||||||||||||||
| 128 | _NS_RDFS_ | ||||||||||||||||||||||||||||
| 129 | _NS_XSI_ | ||||||||||||||||||||||||||||
| 130 | _NS_XSD_ | ||||||||||||||||||||||||||||
| 131 | _NS_XML_ | ||||||||||||||||||||||||||||
| 132 | _NS_TOL_ | ||||||||||||||||||||||||||||
| 133 | _NS_CDAO_ | ||||||||||||||||||||||||||||
| 134 | _NS_BIOPHYLO_ | ||||||||||||||||||||||||||||
| 135 | _NS_SKOS_ | ||||||||||||||||||||||||||||
| 136 | _NS_PHYLOXML_ | ||||||||||||||||||||||||||||
| 137 | _NS_TB2PURL_ | ||||||||||||||||||||||||||||
| 138 | _NS_TNRS_ | ||||||||||||||||||||||||||||
| 139 | _NS_FIGTREE_ | ||||||||||||||||||||||||||||
| 140 | _NS_PHYLOMAP_ | ||||||||||||||||||||||||||||
| 141 | _NS_BIOVEL_ | ||||||||||||||||||||||||||||
| 142 | _NS_NHX_ | ||||||||||||||||||||||||||||
| 143 | _NS_DWC_ | ||||||||||||||||||||||||||||
| 144 | _NS_GBIF_ | ||||||||||||||||||||||||||||
| 145 | ) | ||||||||||||||||||||||||||||
| 146 | ] | ||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | # according to perlsub: | ||||||||||||||||||||||||||||
| 151 | # "Functions with a prototype of () are potential candidates for inlining. | ||||||||||||||||||||||||||||
| 152 | # If the result after optimization and constant folding is either a constant | ||||||||||||||||||||||||||||
| 153 | # or a lexically-scoped scalar which has no other references, then it will | ||||||||||||||||||||||||||||
| 154 | # be used in place of function calls made without & or do." | ||||||||||||||||||||||||||||
| 155 | sub _NS_OWL_ () { 'http://www.w3.org/2002/07/owl#' } | ||||||||||||||||||||||||||||
| 156 | sub _NS_DC_ () { 'http://purl.org/dc/elements/1.1/' } | ||||||||||||||||||||||||||||
| 157 | sub _NS_DCTERMS_ () { 'http://purl.org/dc/terms/' } | ||||||||||||||||||||||||||||
| 158 | sub _NS_NEXML_ () { 'http://www.nexml.org/2009' } | ||||||||||||||||||||||||||||
| 159 | sub _NS_RDF_ () { 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' } | ||||||||||||||||||||||||||||
| 160 | sub _NS_RDFS_ () { 'http://www.w3.org/2000/01/rdf-schema#' } | ||||||||||||||||||||||||||||
| 161 | sub _NS_XSI_ () { 'http://www.w3.org/2001/XMLSchema-instance' } | ||||||||||||||||||||||||||||
| 162 | sub _NS_XSD_ () { 'http://www.w3.org/2001/XMLSchema#' } | ||||||||||||||||||||||||||||
| 163 | sub _NS_XML_ () { 'http://www.w3.org/XML/1998/namespace' } | ||||||||||||||||||||||||||||
| 164 | sub _NS_TOL_ () { 'http://tolweb.org/tree/home.pages/downloadtree.html#' } | ||||||||||||||||||||||||||||
| 165 | sub _NS_CDAO_ () { 'http://www.evolutionaryontology.org/cdao/1.0/cdao.owl#' } | ||||||||||||||||||||||||||||
| 166 | sub _NS_BIOPHYLO_ () { 'http://search.cpan.org/dist/Bio-Phylo/terms#' } | ||||||||||||||||||||||||||||
| 167 | sub _NS_SKOS_ () { 'http://www.w3.org/2004/02/skos/core#' } | ||||||||||||||||||||||||||||
| 168 | sub _NS_PHYLOXML_ () { 'http://www.phyloxml.org/1.10/terms#' } | ||||||||||||||||||||||||||||
| 169 | sub _NS_TB2PURL_ () { 'http://purl.org/phylo/treebase/phylows/' } | ||||||||||||||||||||||||||||
| 170 | sub _NS_TNRS_ () { 'http://phylotastic.org/tnrs/terms#' } | ||||||||||||||||||||||||||||
| 171 | sub _NS_FIGTREE_ () { 'http://tree.bio.ed.ac.uk/software/figtree/terms#' } | ||||||||||||||||||||||||||||
| 172 | sub _NS_PHYLOMAP_ () { 'http://phylomap.org/terms.owl#' } | ||||||||||||||||||||||||||||
| 173 | sub _NS_BIOVEL_ () { 'http://biovel.eu/terms#' } | ||||||||||||||||||||||||||||
| 174 | sub _NS_NHX_ () { 'http://sites.google.com/site/cmzmasek/home/software/forester/nhx' } | ||||||||||||||||||||||||||||
| 175 | sub _NS_DWC_ () { 'http://rs.tdwg.org/dwc/terms/' } | ||||||||||||||||||||||||||||
| 176 | sub _NS_GBIF_ () { 'http://rs.gbif.org/terms/1.0/' } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 57 | our $NS = { | |||||||||||||||||||||||||||
| 179 | 'tnrs' => _NS_TNRS_(), | ||||||||||||||||||||||||||||
| 180 | 'pxml' => _NS_PHYLOXML_(), | ||||||||||||||||||||||||||||
| 181 | 'skos' => _NS_SKOS_(), | ||||||||||||||||||||||||||||
| 182 | 'bp' => _NS_BIOPHYLO_(), | ||||||||||||||||||||||||||||
| 183 | 'cdao' => _NS_CDAO_(), | ||||||||||||||||||||||||||||
| 184 | 'tol' => _NS_TOL_(), | ||||||||||||||||||||||||||||
| 185 | 'xml' => _NS_XML_(), | ||||||||||||||||||||||||||||
| 186 | 'xsd' => _NS_XSD_(), | ||||||||||||||||||||||||||||
| 187 | 'xsi' => _NS_XSI_(), | ||||||||||||||||||||||||||||
| 188 | 'rdf' => _NS_RDF_(), | ||||||||||||||||||||||||||||
| 189 | 'rdfs' => _NS_RDFS_(), | ||||||||||||||||||||||||||||
| 190 | 'nex' => _NS_NEXML_(), | ||||||||||||||||||||||||||||
| 191 | 'dc' => _NS_DC_(), | ||||||||||||||||||||||||||||
| 192 | 'owl' => _NS_OWL_(), | ||||||||||||||||||||||||||||
| 193 | 'bv' => _NS_BIOVEL_(), | ||||||||||||||||||||||||||||
| 194 | 'dcterms' => _NS_DCTERMS_(), | ||||||||||||||||||||||||||||
| 195 | 'fig' => _NS_FIGTREE_(), | ||||||||||||||||||||||||||||
| 196 | 'nhx' => _NS_NHX_(), | ||||||||||||||||||||||||||||
| 197 | 'dwc' => _NS_DWC_(), | ||||||||||||||||||||||||||||
| 198 | 'gbif' => _NS_GBIF_(), | ||||||||||||||||||||||||||||
| 199 | }; | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | sub _NEXML_VERSION_ () { '0.9' } | ||||||||||||||||||||||||||||
| 202 | sub _NONE_ () { Bio::Phylo::Util::CONSTANT::Int::_NONE_ } | ||||||||||||||||||||||||||||
| 203 | sub _NODE_ () { Bio::Phylo::Util::CONSTANT::Int::_NODE_ } | ||||||||||||||||||||||||||||
| 204 | sub _TREE_ () { Bio::Phylo::Util::CONSTANT::Int::_TREE_ } | ||||||||||||||||||||||||||||
| 205 | sub _FOREST_ () { Bio::Phylo::Util::CONSTANT::Int::_FOREST_ } | ||||||||||||||||||||||||||||
| 206 | sub _TAXON_ () { Bio::Phylo::Util::CONSTANT::Int::_TAXON_ } | ||||||||||||||||||||||||||||
| 207 | sub _TAXA_ () { Bio::Phylo::Util::CONSTANT::Int::_TAXA_ } | ||||||||||||||||||||||||||||
| 208 | sub _DATUM_ () { Bio::Phylo::Util::CONSTANT::Int::_DATUM_ } | ||||||||||||||||||||||||||||
| 209 | sub _MATRIX_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRIX_ } | ||||||||||||||||||||||||||||
| 210 | sub _MATRICES_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRICES_ } | ||||||||||||||||||||||||||||
| 211 | sub _SEQUENCE_ () { Bio::Phylo::Util::CONSTANT::Int::_SEQUENCE_ } | ||||||||||||||||||||||||||||
| 212 | sub _ALIGNMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_ALIGNMENT_ } | ||||||||||||||||||||||||||||
| 213 | sub _CHAR_ () { Bio::Phylo::Util::CONSTANT::Int::_CHAR_ } | ||||||||||||||||||||||||||||
| 214 | sub _PROJECT_ () { Bio::Phylo::Util::CONSTANT::Int::_PROJECT_ } | ||||||||||||||||||||||||||||
| 215 | sub _CHARSTATE_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARSTATE_ } | ||||||||||||||||||||||||||||
| 216 | sub _CHARSTATESEQ_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARSTATESEQ_ } | ||||||||||||||||||||||||||||
| 217 | sub _MATRIXROW_ () { Bio::Phylo::Util::CONSTANT::Int::_MATRIXROW_ } | ||||||||||||||||||||||||||||
| 218 | sub _ANNOTATION_ () { Bio::Phylo::Util::CONSTANT::Int::_ANNOTATION_ } | ||||||||||||||||||||||||||||
| 219 | sub _DICTIONARY_ () { Bio::Phylo::Util::CONSTANT::Int::_DICTIONARY_ } | ||||||||||||||||||||||||||||
| 220 | sub _DOMCREATOR_ () { Bio::Phylo::Util::CONSTANT::Int::_DOMCREATOR_ } | ||||||||||||||||||||||||||||
| 221 | sub _META_ () { Bio::Phylo::Util::CONSTANT::Int::_META_ } | ||||||||||||||||||||||||||||
| 222 | sub _DESCRIPTION_ () { Bio::Phylo::Util::CONSTANT::Int::_DESCRIPTION_ } | ||||||||||||||||||||||||||||
| 223 | sub _RESOURCE_ () { Bio::Phylo::Util::CONSTANT::Int::_RESOURCE_ } | ||||||||||||||||||||||||||||
| 224 | sub _DOCUMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_DOCUMENT_ } | ||||||||||||||||||||||||||||
| 225 | sub _ELEMENT_ () { Bio::Phylo::Util::CONSTANT::Int::_ELEMENT_ } | ||||||||||||||||||||||||||||
| 226 | sub _CHARACTERS_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARACTERS_ } | ||||||||||||||||||||||||||||
| 227 | sub _CHARACTER_ () { Bio::Phylo::Util::CONSTANT::Int::_CHARACTER_ } | ||||||||||||||||||||||||||||
| 228 | sub _SET_ () { Bio::Phylo::Util::CONSTANT::Int::_SET_ } | ||||||||||||||||||||||||||||
| 229 | sub _MODEL_ () { Bio::Phylo::Util::CONSTANT::Int::_MODEL_ } | ||||||||||||||||||||||||||||
| 230 | sub _OPERATION_ () { Bio::Phylo::Util::CONSTANT::Int::_OPERATION_ } | ||||||||||||||||||||||||||||
| 231 | sub _DATATYPE_ () { Bio::Phylo::Util::CONSTANT::Int::_DATATYPE_ } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # for PhyloWS | ||||||||||||||||||||||||||||
| 234 | sub _HTTP_SC_SEE_ALSO_ () { '303 See Other' } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | # for tree drawing | ||||||||||||||||||||||||||||
| 237 | sub _PI_ () { 4 * atan2(1,1) } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | # this is a drop in replacement for Scalar::Util's function | ||||||||||||||||||||||||||||
| 240 | 57 | my $looks_like_number; | |||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||
| 242 | 57 | eval { Scalar::Util::looks_like_number(0) }; | |||||||||||||||||||||||||||
| 243 | 57 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | my $LOOKS_LIKE_NUMBER_RE = | |||||||||||||||||||||||||||
| 245 | qr/^([-+]?\d+(\.\d+)?([eE][-+]\d+)?|Inf|NaN)$/; | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $looks_like_number = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 247 | 0 | my $num = shift; | |||||||||||||||||||||||||||
| 248 | 0 | ▶ | if ( defined $num and $num =~ $LOOKS_LIKE_NUMBER_RE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $num and $num =~ /$LOOKS_LIKE_NUMBER_RE/
MC/DC0%0/2
defined $num and $num =~ /$LOOKS_LIKE_NUMBER_RE/
defined $num
$num =~ /$LOOKS_LIKE_NUMBER_RE/
Truth table0%0/3
A and B
A= defined $numB= $num =~ /$LOOKS_LIKE_NUMBER_RE/
| |||||||||||||||||||||||||||||
| 249 | 0 | return 1; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||
| 252 | 0 | return; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | 0 | } | |||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||
| 257 | 57 | $looks_like_number = \&Scalar::Util::looks_like_number; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | 57 | undef($@); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 55364 | ▶ | sub looks_like_number($) { return $looks_like_number->(shift) } | ||||||||||||||||||||||||||
|
Subroutine
looks_like_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 21201 | ▶ | sub looks_like_object($$) { | ||||||||||||||||||||||||||
|
Subroutine
looks_like_object: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | 21201 | my ( $object, $constant ) = @_; | |||||||||||||||||||||||||||
| 265 | 21201 | my $type; | |||||||||||||||||||||||||||
| 266 | 21201 | eval { $type = $object->_type }; | |||||||||||||||||||||||||||
| 267 | 21201 | ▶ | if ( $@ or $type != $constant ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$@ or $type != $constant
MC/DC100%2/2
$@ or $type != $constant
$@
$type != $constant
Truth table100%3/3
A or B
A= $@B= $type != $constant
| |||||||||||||||||||||||||||||
| 268 | 20 | throw 'ObjectMismatch' => 'Invalid object!'; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | else { | ||||||||||||||||||||||||||||
| 271 | 21181 | return 1; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 11082 | ▶ | sub looks_like_implementor($$) { | ||||||||||||||||||||||||||
|
Subroutine
looks_like_implementor: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 276 | 11082 | return UNIVERSAL::can( $_[0], $_[1] ); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 90528 | ▶ | sub looks_like_instance($$) { | ||||||||||||||||||||||||||
|
Subroutine
looks_like_instance: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 280 | 90528 | my ( $object, $class ) = @_; | |||||||||||||||||||||||||||
| 281 | 90528 | ▶ | if ( ref $object ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | 88112 | ▶ | if ( blessed $object ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 218 | return $object->isa($class); | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | else { | ||||||||||||||||||||||||||||
| 286 | 87894 | return ref $object eq $class; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | else { | ||||||||||||||||||||||||||||
| 290 | 2416 | return; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 16251 | ▶ | sub looks_like_hash(@) { | ||||||||||||||||||||||||||
|
Subroutine
looks_like_hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 16251 | ▶ | if ( scalar(@_) % 2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | 1 | throw 'OddHash' => 'Odd number of elements in hash assignment'; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | else { | ||||||||||||||||||||||||||||
| 299 | 16250 | return @_; | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 1699 | ▶ | sub looks_like_class($) { | ||||||||||||||||||||||||||
|
Subroutine
looks_like_class: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 304 | 1699 | my $class = shift; | |||||||||||||||||||||||||||
| 305 | 1699 | my $path = $class; | |||||||||||||||||||||||||||
| 306 | 1699 | $path =~ s|::|/|g; | |||||||||||||||||||||||||||
| 307 | 1699 | $path .= '.pm'; | |||||||||||||||||||||||||||
| 308 | 1699 | ▶ | if ( not exists $INC{$path} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 178 | eval { require $path }; | |||||||||||||||||||||||||||
| 310 | 178 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 96 | throw 'ExtensionError' => $@; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | 1603 | return $class; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | 57 | 1; | |||||||||||||||||||||||||||
| 317 | __END__ | ||||||||||||||||||||||||||||