| 1 | package Biblio::ILL::ISO::ILLASNtype; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 4 | our $VERSION = '0.01'; | |||||||||||||||||||
| 6 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 7 | # Mods | ||||||||||||||||||||
| 8 | # 0.01 - 2003.07.15 - original version | ||||||||||||||||||||
| 9 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | # From the ASN | ||||||||||||||||||||
| 12 | # | ||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 17 | # | ||||||||||||||||||||
| 18 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 19 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 20 | 0 | my $class = shift; | |||||||||||||||||||
| 21 | 0 | my $self = {}; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | ▶ | bless($self, ref($class) || $class); | ||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 24 | 0 | return ($self); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 29 | # | ||||||||||||||||||||
| 30 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 31 | 0 | ▶ | sub as_string { | ||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | return "ILLASNtype as_string().... should be virtual!"; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 38 | # | ||||||||||||||||||||
| 39 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 40 | 0 | ▶ | sub as_pretty_string { | ||||||||||||||||||
|
Subroutine
as_pretty_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | return _debug_print($self,4); | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 47 | # This will return a structure usable by Convert::ASN1 | ||||||||||||||||||||
| 48 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 49 | 483 | ▶ | sub as_asn { | ||||||||||||||||||
|
Subroutine
as_asn: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 50 | 483 | my $self = shift; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 483 | my %h = (); | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 483 | foreach my $key (sort keys %$self) { | |||||||||||||||||||
| 55 | #print " [$key]\n"; | ||||||||||||||||||||
| 56 | 675 | ▶ | if ( not ref($self->{$key}) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 214 | $h{$key} = $self->{$key}; | |||||||||||||||||||
| 58 | #print " " . $h{$key} . "\n"; | ||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||
| 60 | 461 | $h{$key} = $self->{$key}->as_asn(); | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 483 | return \%h; | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 68 | # | ||||||||||||||||||||
| 69 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 70 | 0 | ▶ | sub from_asn { | ||||||||||||||||||
|
Subroutine
from_asn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||
| 72 | 0 | my $href = shift; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | # does nothing | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | return $self; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 81 | # | ||||||||||||||||||||
| 82 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 83 | 0 | ▶ | sub _debug_print { | ||||||||||||||||||
|
Subroutine
_debug_print: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 84 | # my $self = shift; | ||||||||||||||||||||
| 85 | 0 | my ($ref, $indent) = @_; | |||||||||||||||||||
| 86 | 0 | my $s = ""; | |||||||||||||||||||
| 87 | 0 | ▶ | $indent = 0 if (not defined($indent)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | # return _debug_print_hash($self) if (not defined $ref); | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | # print ">>>" . ref($ref) . "<<<\n"; | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | return _debug_print_hash($ref, $indent) if (ref($ref) eq "HASH"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 94 | 0 | ▶ | return _debug_print_array($ref, $indent) if (ref($ref) eq "ARRAY"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | ▶ | for ($i=0; $i < $indent; $i++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 97 | 0 | $s .= " "; | |||||||||||||||||||
| 98 | #print "."; # DC - debugging | ||||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | #print "\n"; # DC - debugging | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 0 | ▶ | return ("$s$ref\n") if (not ref($ref)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | # If it's not any of the above, it is (should be?) an object, | ||||||||||||||||||||
| 105 | # which we treat as a hash. Cheezy, I know - I can't think | ||||||||||||||||||||
| 106 | # of a better way. | ||||||||||||||||||||
| 107 | 0 | return _debug_print_hash($ref, $indent); | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 112 | # | ||||||||||||||||||||
| 113 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 114 | 0 | ▶ | sub _debug_print_hash { | ||||||||||||||||||
|
Subroutine
_debug_print_hash: not called CC=7 SCAR=40.3
| |||||||||||||||||||||
| 115 | 0 | my ($href, $indent) = @_; | |||||||||||||||||||
| 116 | 0 | my $s = ""; | |||||||||||||||||||
| 117 | 0 | ▶ | $indent = 0 if (not defined($indent)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 0 | foreach $key (sort keys %$href) { | |||||||||||||||||||
| 120 | # There's got to be a better way :-) | ||||||||||||||||||||
| 121 | 0 | ▶ | for ($i=0; $i < $indent; $i++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | 0 | $s .= " "; | |||||||||||||||||||
| 123 | #print "."; # DC - debugging | ||||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | #print "\n"; # DC - debugging | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 0 | $s .= "$key "; | |||||||||||||||||||
| 128 | 0 | ▶ | $s .= "=>\n" unless (ref($href->{$key}) eq "HASH"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 129 | 0 | ▶ | $s .= "\n" if (ref($href->{$key}) eq "HASH"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 130 | 0 | ▶ | $s .= "\n" if (ref($href->{$key}) eq "ARRAY"); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 131 | 0 | $s .= _debug_print($href->{$key}, $indent+4); | |||||||||||||||||||
| 132 | } | ||||||||||||||||||||
| 133 | 0 | return $s; | |||||||||||||||||||
| 134 | } | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 138 | # | ||||||||||||||||||||
| 139 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 140 | 0 | ▶ | sub _debug_print_array { | ||||||||||||||||||
|
Subroutine
_debug_print_array: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 141 | 0 | my ($aref, $indent) = @_; | |||||||||||||||||||
| 142 | 0 | my $s = ""; | |||||||||||||||||||
| 143 | 0 | ▶ | $indent = 0 if (not defined($indent)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 0 | foreach $elm (@$aref) { | |||||||||||||||||||
| 146 | # There's got to be a better way :-) | ||||||||||||||||||||
| 147 | 0 | ▶ | for ($i=0; $i < $indent; $i++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 148 | 0 | $s .= " "; | |||||||||||||||||||
| 149 | #print "."; # DC - debugging | ||||||||||||||||||||
| 150 | } | ||||||||||||||||||||
| 151 | #print "\n"; # DC - debugging | ||||||||||||||||||||
| 152 | 0 | $s .= _debug_print($elm, $indent+4); | |||||||||||||||||||
| 153 | } | ||||||||||||||||||||
| 154 | 0 | return $s; | |||||||||||||||||||
| 155 | } | ||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 4 | 1; | |||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | |||||||||||||||||||||