| 1 | package MARC::Convert::Wikidata::Utils; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 61 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 61 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 61 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 61 | ▶ | use List::Util 1.33 qw(none sum); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 61 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 61 | ▶ | use Roman; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 61 | ▶ | use Unicode::UTF8 qw(decode_utf8 encode_utf8); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 61 | Readonly::Array our @EXPORT_OK => qw(clean_cover clean_date clean_isbn clean_issn | |||||||||||||||||||||||||||||||||||||||||
| 13 | clean_edition_number clean_number_of_pages clean_oclc clean_publication_date | ||||||||||||||||||||||||||||||||||||||||||
| 14 | clean_publisher_name clean_publisher_place clean_series_name clean_series_ordinal | ||||||||||||||||||||||||||||||||||||||||||
| 15 | clean_subtitle clean_title look_for_external_id); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 61 | Readonly::Array our @COVERS => qw(hardback paperback); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 61 | our $VERSION = 0.34; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 61 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 59 | ▶ | sub clean_cover { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_cover: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 59 | my $cover = shift; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 59 | ▶ | if (! defined $cover) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 58 | my $ret_cover = $cover; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 58 | $ret_cover =~ s/\s*:\s*$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 58 | $ret_cover =~ s/\s*;\s*$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 58 | $ret_cover =~ s/^\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 58 | $ret_cover =~ s/^\(\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 58 | $ret_cover =~ s/\s*\)$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | # Hardback | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 58 | my $c = decode_utf8('(v|V)áz'); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 58 | $ret_cover =~ s/^$c\.?$/hardback/ms; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 58 | $c = decode_utf8('(v|V)ázáno'); | |||||||||||||||||||||||||||||||||||||||||
| 39 | 58 | $ret_cover =~ s/^$c$/hardback/ms; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | # Paperback | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 58 | $c = decode_utf8('(b|B)rož'); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 58 | $ret_cover =~ s/^$c\.?$/paperback/ms; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 58 | $c = decode_utf8('(b|B)rožováno'); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 58 | $ret_cover =~ s/^$c$/paperback/ms; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # Collective. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 58 | $c = decode_utf8('svazků'); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 58 | $ret_cover =~ s/soubor\s+\d+\s+$c/collective/ms; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 58 | $ret_cover =~ s/soubor\s*\d*/collective/ms; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 58 | ▶ | if (none { $ret_cover eq $_ } (@COVERS, 'collective')) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | warn "Book cover '$ret_cover' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | $ret_cover = undef; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 58 | return $ret_cover; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 69 | ▶ | sub clean_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_date: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 69 | my $date = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 69 | ▶ | if (! defined $date) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 68 | ▶ | if (! $date) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 56 | my $options_hr = {}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 56 | my $months_hr = { | |||||||||||||||||||||||||||||||||||||||||
| 75 | 'leden' => '01', | ||||||||||||||||||||||||||||||||||||||||||
| 76 | decode_utf8('únor') => '02', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | decode_utf8('březen') => '03', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 'duben' => '04', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | decode_utf8('květen') => '05', | ||||||||||||||||||||||||||||||||||||||||||
| 80 | decode_utf8('červen') => '06', | ||||||||||||||||||||||||||||||||||||||||||
| 81 | decode_utf8('červenec') => '07', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 'srpen' => '08', | ||||||||||||||||||||||||||||||||||||||||||
| 83 | decode_utf8('září') => '09', | ||||||||||||||||||||||||||||||||||||||||||
| 84 | decode_utf8('říjen') => '10', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 'listopad' => '11', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 'prosinec' => '12', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 56 | my $ret_date = $date; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # Date is circa. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 56 | ▶ | if ($ret_date =~ s/^c(.*)$/$1/ms || $ret_date =~ s/^asi (.*)$/$1/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ret_date =~ s/^c(.*)$/$1/ms or $ret_date =~ s/^asi (.*)$/$1/ms
MC/DC100%2/2
$ret_date =~ s/^c(.*)$/$1/ms or $ret_date =~ s/^asi (.*)$/$1/ms
$ret_date =~ s/^c(.*)$/$1/ms
$ret_date =~ s/^asi (.*)$/$1/ms
Truth table100%3/3
A or B
A= $ret_date =~ s/^c(.*)$/$1/msB= $ret_date =~ s/^asi (.*)$/$1/ms
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | $options_hr->{'circa'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 56 | foreach my $month (keys %{$months_hr}) { | |||||||||||||||||||||||||||||||||||||||||
| 97 | 672 | $ret_date =~ s/^(\d{4})\s*$month\s*(\d+)\.$/$1-$months_hr->{$month}-$2/ms; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 56 | my $bk = decode_utf8('př. Kr.'); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 56 | $ret_date =~ s/^(\d+)\s*$bk/-$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 56 | my $ak = decode_utf8('po. Kr.'); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 56 | $ret_date =~ s/^(\d+)\s*$ak/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 56 | $ret_date =~ s/\s*\.$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 56 | ▶ | if ($ret_date !~ m/^\-?\d+(\-\d+)?(\-\d+)?$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | warn "Date '$date' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $ret_date = undef; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 56 | ▶ | return wantarray ? ($ret_date, $options_hr) : $ret_date; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 92 | ▶ | sub clean_edition_number { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_edition_number: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 92 | my $edition_number = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 92 | ▶ | if (! defined $edition_number) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 91 | my $ret_edition_number = $edition_number; | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Remove [] on begin and end. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 91 | $ret_edition_number = _remove_square_brackets($ret_edition_number); | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | # Remove trailing whitespace | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 91 | $ret_edition_number = _remove_trailing_whitespace($ret_edition_number); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # Remove special meanings. | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 91 | $ret_edition_number =~ s/,//msg; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | # Edition. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 91 | my $v1 = decode_utf8('Vydání'); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 91 | my $v2 = decode_utf8('vydání'); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 91 | $ret_edition_number =~ s/\s*(Vyd\.|vyd\.|$v1|$v2|Vydanie|vydanie|vyd|published)//gx; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 91 | $ret_edition_number =~ s/English edition//ms; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 91 | $ret_edition_number =~ s/\s*rozmn\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 91 | my $re = decode_utf8('souborné'); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # Authorized. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 91 | $ret_edition_number =~ s/\s*aut\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 91 | $ret_edition_number =~ s/\s*autoris\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 91 | $ret_edition_number =~ s/\s*autoriz\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 91 | $re = decode_utf8('autorisované'); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # Extended. | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 91 | $re = decode_utf8('přeprac'); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 91 | $ret_edition_number =~ s/\s*$re\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 91 | $re = decode_utf8('nezměněné'); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 91 | $re = decode_utf8('nezměn'); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 91 | $ret_edition_number =~ s/\s*$re\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 91 | $re = decode_utf8('přepracované'); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 91 | $ret_edition_number =~ s/\s*aktualiz\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 91 | $re = decode_utf8('aktualizované'); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 91 | $re = decode_utf8('značně'); | |||||||||||||||||||||||||||||||||||||||||
| 163 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 91 | $ret_edition_number =~ s/\s*nezm\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 91 | $re = decode_utf8('rozšířené'); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 91 | $re = decode_utf8('rozmnožené'); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 91 | $re = decode_utf8('rozš'); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 91 | $ret_edition_number =~ s/\s*$re\.?//ms; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 91 | $ret_edition_number =~ s/\s*dopl\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 91 | $ret_edition_number =~ s/\s*dopln\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 91 | $re = decode_utf8('doplněné'); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 91 | $re = decode_utf8('upravené'); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 91 | $ret_edition_number =~ s/\s*upr\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 91 | $ret_edition_number =~ s/\s*opr\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 91 | $ret_edition_number =~ s/\s*oprav\.//ms; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 91 | $re = decode_utf8('revidované'); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 91 | $ret_edition_number =~ s/\s*zcela//ms; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 91 | $re = decode_utf8('v této'); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 91 | $re = decode_utf8('V této'); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 91 | $ret_edition_number =~ s/\s*V\stomto\ssouboru//ms; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 91 | $re = decode_utf8('podobě'); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 91 | $re = decode_utf8('část'); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 91 | $ret_edition_number =~ s/\s*$re\.?//ms; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | # Czech. | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 91 | $re = decode_utf8('(v|V) českém jazyce'); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 91 | $re = decode_utf8('(Č|č)eské'); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 91 | $re = decode_utf8('(Č|č)es\.'); | |||||||||||||||||||||||||||||||||||||||||
| 199 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 91 | $re = decode_utf8('(v|V) češtině\s*'); | |||||||||||||||||||||||||||||||||||||||||
| 201 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | # With illustration. | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 91 | $re = decode_utf8('s vyobrazeními'); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 91 | $ret_edition_number =~ s/\s*$re//ms; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # Remove trailing whitespace | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 91 | $ret_edition_number = _remove_trailing_whitespace($ret_edition_number); | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # Rewrite number in Czech to number. | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 91 | my $dict_hr = { | |||||||||||||||||||||||||||||||||||||||||
| 212 | decode_utf8('První') => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | decode_utf8('Prvé') => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 214 | decode_utf8('první') => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 'First' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 216 | decode_utf8('prvé') => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | decode_utf8('Druhé') => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | decode_utf8('druhé') => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | decode_utf8('Třetí') => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 220 | decode_utf8('třetí') => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | decode_utf8('Čtvrté') => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | decode_utf8('čtvrté') => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | decode_utf8('Páté') => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | decode_utf8('páté') => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 225 | decode_utf8('Šesté') => 6, | ||||||||||||||||||||||||||||||||||||||||||
| 226 | decode_utf8('šesté') => 6, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | decode_utf8('Sedmé') => 7, | ||||||||||||||||||||||||||||||||||||||||||
| 228 | decode_utf8('sedmé') => 7, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | decode_utf8('Osmé') => 8, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | decode_utf8('osmé') => 8, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | decode_utf8('Deváté') => 9, | ||||||||||||||||||||||||||||||||||||||||||
| 232 | decode_utf8('deváté') => 9, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | decode_utf8('Desáté') => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | decode_utf8('desáté') => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | decode_utf8('Dvacáté') => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | decode_utf8('dvacáté') => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 91 | foreach my $origin (keys %{$dict_hr}) { | |||||||||||||||||||||||||||||||||||||||||
| 239 | 2275 | $ret_edition_number =~ s/\s*$origin\s*/$dict_hr->{$origin}/ms; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | # Remove dots. | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 91 | $ret_edition_number =~ s/\s*\.\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | # Remove : | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 91 | $ret_edition_number =~ s/\s*:\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # Detect first number. | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 91 | $ret_edition_number =~ s/^(\d+)(?!.*\d).*$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # Rename roman to arabic | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 91 | ▶ | if (isroman($ret_edition_number)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | $ret_edition_number = arabic($ret_edition_number); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 91 | ▶ | if ($ret_edition_number !~ m/^\d+$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 7 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | warn encode_utf8("Edition number '$edition_number' couldn't clean ($ret_edition_number)."); | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 7 | $ret_edition_number = undef; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 91 | return $ret_edition_number; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 16 | ▶ | sub clean_isbn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_isbn: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 16 | my $isbn = shift; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 16 | ▶ | if (! defined $isbn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 16 | my $ret_isbn = $isbn; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 16 | $ret_isbn =~ s/\s+:?$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 16 | ▶ | if ($ret_isbn !~ m/^[\d\-]+$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | warn "ISBN '$ret_isbn' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $ret_isbn = undef; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 16 | return $ret_isbn; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 15 | ▶ | sub clean_issn { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_issn: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 15 | my $issn = shift; | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 15 | ▶ | if (! defined $issn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | my $ret_issn = $issn; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | $ret_issn =~ s/\s+;?$//ms; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | if ($ret_issn !~ m/^\d{4}-\d{4}$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | warn "ISSN '$ret_issn' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $ret_issn = undef; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | return $ret_issn; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 38 | ▶ | sub clean_number_of_pages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_number_of_pages: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 38 | my $number_of_pages = shift; | |||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 38 | ▶ | if (! defined $number_of_pages) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 36 | my $ret_number_of_pages = $number_of_pages; | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | # Remove [] | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 36 | $ret_number_of_pages =~ s/\[(\d+)\]/$1/msg; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | # Remove text informations. | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 36 | my $pril = decode_utf8('příl'); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 36 | my $neci = decode_utf8('nečíslovaných'); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 36 | $ret_number_of_pages =~ s/\s*(stran|s|$pril|$neci|l|barev|obr)\.*\s*//msg; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # Remove other characters like ':' and ';'. | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 36 | $ret_number_of_pages =~ s/[:;]//msg; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | # TODO Support roman numbers. | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 36 | ▶ | if ($ret_number_of_pages =~ m/^[\ \d,]+$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 33 | my @numbers = split m/\s*,\s*/ms, $ret_number_of_pages; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 33 | $ret_number_of_pages = sum(@numbers); | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 36 | ▶ | if ($ret_number_of_pages !~ m/^\d+$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 3 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | warn "Number of pages '$number_of_pages' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | $ret_number_of_pages = undef; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 36 | return $ret_number_of_pages; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 30 | ▶ | sub clean_oclc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_oclc: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 30 | my $oclc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 30 | ▶ | if (! defined $oclc) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 30 | my $ret_oclc = $oclc; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 30 | $ret_oclc =~ s/^\(OCoLC\)//ms; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 30 | return $ret_oclc; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 8 | ▶ | sub clean_publication_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_publication_date: called CC=11 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 8 | my $publication_date = shift; | |||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 8 | my $ret_publication_date = $publication_date; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 8 | my ($start_date, $end_date, $dash); | |||||||||||||||||||||||||||||||||||||||||
| 361 | 8 | ▶ | if ($ret_publication_date =~ m/^([^-]+)(\-?)(.*)$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 8 | $start_date = $1; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 8 | $dash = $2; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | $end_date = $3; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | # Remove [] on begin and end. | ||||||||||||||||||||||||||||||||||||||||||
| 368 | # XXX [] is circa | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 8 | $start_date = _remove_square_brackets($start_date); | |||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | ▶ | if (defined $end_date) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 8 | $end_date = _remove_square_brackets($end_date); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | # Detect circa. | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 8 | my $option; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 8 | foreach my $date ($start_date, $end_date) { | |||||||||||||||||||||||||||||||||||||||||
| 377 | 16 | ▶ | if (defined $date && ($date =~ s/^c(.*)$/$1/ms | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $date and $date =~ s/^c(.*)$/$1/ms || $date =~ s/^(.*)\?$/$1/ms
$date =~ s/^c(.*)$/$1/ms or $date =~ s/^(.*)\?$/$1/ms
MC/DC66%2/3
defined $date and $date =~ s/^c(.*)$/$1/ms || $date =~ s/^(.*)\?$/$1/ms
defined $date
$date =~ s/^c(.*)$/$1/ms
$date =~ s/^(.*)\?$/$1/ms
Truth table75%3/4
A and B or C
A= defined $dateB= $date =~ s/^c(.*)$/$1/msC= $date =~ s/^(.*)\?$/$1/ms
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | || $date =~ s/^(.*)\?$/$1/ms)) { | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | # XXX Circa of start and end | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 3 | $option = 'circa'; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | # Combine back. | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 8 | $ret_publication_date = $start_date; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 8 | ▶ | if ($dash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | $ret_publication_date .= $dash; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | ▶ | if ($end_date) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | $ret_publication_date .= $end_date; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 8 | ▶ | if ($ret_publication_date !~ m/^(\d+)\-?(.*)$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | warn "Publication date '$publication_date' couldn't clean."; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | $ret_publication_date = undef; | |||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 8 | return ($ret_publication_date, $option); | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 54 | ▶ | sub clean_publisher_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_publisher_name: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 54 | my $publisher_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 54 | ▶ | if (! defined $publisher_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 54 | my $ret_publisher_name = $publisher_name; | |||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | # Trailing whitespace on begin and end | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 54 | $ret_publisher_name = _remove_trailing_whitespace($ret_publisher_name); | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | # Separators on the end. | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 54 | $ret_publisher_name =~ s/\s*,$//g; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 54 | $ret_publisher_name =~ s/\s*:$//g; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 54 | $ret_publisher_name =~ s/\s*;$//g; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | # Remove ( from begin and not ending. | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 54 | $ret_publisher_name =~ s/^\(([^\)]+)$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | # Remove [] on begin and end. | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 54 | $ret_publisher_name = _remove_square_brackets($ret_publisher_name); | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 54 | return $ret_publisher_name; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 84 | ▶ | sub clean_publisher_place { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_publisher_place: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 84 | my $publisher_place = shift; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 84 | ▶ | if (! defined $publisher_place) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 84 | my $dict_hr = { | |||||||||||||||||||||||||||||||||||||||||
| 439 | 'Blansku' => 'Blansko', | ||||||||||||||||||||||||||||||||||||||||||
| 440 | decode_utf8('w Cieszynie') => decode_utf8('Cieszyn'), | ||||||||||||||||||||||||||||||||||||||||||
| 441 | decode_utf8('Č. Budějovice') => decode_utf8('České Budějovice'), | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 'Plzni' => decode_utf8('Plzeň'), | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 'Prag' => 'Praha', | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 'Praze' => 'Praha', | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 'W Praze' => 'Praha', | ||||||||||||||||||||||||||||||||||||||||||
| 446 | decode_utf8('Pardubicích') => 'Pardubice', | ||||||||||||||||||||||||||||||||||||||||||
| 447 | decode_utf8('Brně') => 'Brno', | ||||||||||||||||||||||||||||||||||||||||||
| 448 | decode_utf8('Hradci Králové') => decode_utf8('Hradec Králové'), | ||||||||||||||||||||||||||||||||||||||||||
| 449 | decode_utf8('Jičíně') => decode_utf8('Jičín'), | ||||||||||||||||||||||||||||||||||||||||||
| 450 | decode_utf8('Jihlavě') => 'Jihlava', | ||||||||||||||||||||||||||||||||||||||||||
| 451 | decode_utf8('Jimramově') => 'Jimramov', | ||||||||||||||||||||||||||||||||||||||||||
| 452 | decode_utf8('Karlových Varech') => 'Karlovy Vary', | ||||||||||||||||||||||||||||||||||||||||||
| 453 | decode_utf8('Kolíně') => decode_utf8('Kolín'), | ||||||||||||||||||||||||||||||||||||||||||
| 454 | decode_utf8('Kroměříži') => decode_utf8('Kroměříž'), | ||||||||||||||||||||||||||||||||||||||||||
| 455 | decode_utf8('Hoře Kutné') => decode_utf8('Kutná Hora'), | ||||||||||||||||||||||||||||||||||||||||||
| 456 | decode_utf8('Kutné Hoře') => decode_utf8('Kutná Hora'), | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 'Liberci' => 'Liberec', | ||||||||||||||||||||||||||||||||||||||||||
| 458 | decode_utf8('Litoměřicích') => decode_utf8('Litoměřice'), | ||||||||||||||||||||||||||||||||||||||||||
| 459 | decode_utf8('Náchodě') => decode_utf8('Náchod'), | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 'Nymburce' => 'Nymburk', | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 'Olomouci' => 'Olomouc', | ||||||||||||||||||||||||||||||||||||||||||
| 462 | decode_utf8('Ostravě') => 'Ostrava', | ||||||||||||||||||||||||||||||||||||||||||
| 463 | decode_utf8('Poděbradech') => decode_utf8('Poděbrady'), | ||||||||||||||||||||||||||||||||||||||||||
| 464 | decode_utf8('Přelouči') => decode_utf8('Přelouč'), | ||||||||||||||||||||||||||||||||||||||||||
| 465 | decode_utf8('Přerově') => decode_utf8('Přerov'), | ||||||||||||||||||||||||||||||||||||||||||
| 466 | decode_utf8('Řevnicích') => decode_utf8('Řevnice'), | ||||||||||||||||||||||||||||||||||||||||||
| 467 | decode_utf8('Stříbře') => decode_utf8('Stříbro'), | ||||||||||||||||||||||||||||||||||||||||||
| 468 | decode_utf8('Telči') => decode_utf8('Telč'), | ||||||||||||||||||||||||||||||||||||||||||
| 469 | decode_utf8('Třebíč na Moravě') => decode_utf8('Třebíč'), | ||||||||||||||||||||||||||||||||||||||||||
| 470 | decode_utf8('Třebíči') => decode_utf8('Třebíč'), | ||||||||||||||||||||||||||||||||||||||||||
| 471 | decode_utf8('Třebíči na Moravě') => decode_utf8('Třebíč'), | ||||||||||||||||||||||||||||||||||||||||||
| 472 | decode_utf8('Vyškově') => decode_utf8('Vyškov'), | ||||||||||||||||||||||||||||||||||||||||||
| 473 | decode_utf8('Zlíně') => decode_utf8('Zlín'), | ||||||||||||||||||||||||||||||||||||||||||
| 474 | # No place. | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 'S.l.' => 'sine loco', | ||||||||||||||||||||||||||||||||||||||||||
| 476 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 84 | my $ret_publisher_place = $publisher_place; | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 84 | $ret_publisher_place =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 84 | $ret_publisher_place =~ s/\s*:$//g; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 84 | $ret_publisher_place =~ s/\s*;$//g; | |||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | # [V Praze] | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 84 | $ret_publisher_place =~ s/^\[(.*?)\]?$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 84 | $ret_publisher_place =~ s/^[vVW]e?\s+//ms; | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 84 | foreach my $origin (keys %{$dict_hr}) { | |||||||||||||||||||||||||||||||||||||||||
| 490 | 3024 | $ret_publisher_place =~ s/^$origin$/$dict_hr->{$origin}/ms; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 84 | $ret_publisher_place =~ s/^[VW]e?\s+([\s\w]+)$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 494 | # [Praha] | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 84 | $ret_publisher_place =~ s/^\[(.*?)\]$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 84 | $ret_publisher_place =~ s/^(.*)\?$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 84 | return $ret_publisher_place; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 17 | ▶ | sub clean_series_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_series_name: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 17 | my $series_name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 17 | ▶ | if (! defined $series_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 17 | my $ret_series_name = $series_name; | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | # Trailing whitespace on begin and end | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 17 | $ret_series_name = _remove_trailing_whitespace($ret_series_name); | |||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 17 | $ret_series_name =~ s/\s*;$//g; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 17 | $ret_series_name =~ s/\s*:$//g; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 17 | $ret_series_name =~ s/\s*,$//g; | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # Remove [] on begin and end. | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 17 | $ret_series_name = _remove_square_brackets($ret_series_name); | |||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 17 | return $ret_series_name; | |||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 37 | ▶ | sub clean_series_ordinal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_series_ordinal: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 37 | my $series_ordinal = shift; | |||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 37 | ▶ | if (! defined $series_ordinal) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 33 | my $ret_series_ordinal = $series_ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # Trailing whitespace on begin and end | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 33 | $ret_series_ordinal = _remove_trailing_whitespace($ret_series_ordinal); | |||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 33 | $ret_series_ordinal =~ s/^(S|s)v\.\s*//g; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 33 | $ret_series_ordinal =~ s/^svazek\s*//g; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 33 | $ret_series_ordinal =~ s/\s*svazek$//g; | |||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | 33 | my $c = decode_utf8('(č|Č)'); | |||||||||||||||||||||||||||||||||||||||||
| 541 | 33 | $ret_series_ordinal =~ s/^$c\.\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 542 | 33 | $c = decode_utf8('(sešit|seš|Seš)'); | |||||||||||||||||||||||||||||||||||||||||
| 543 | 33 | $ret_series_ordinal =~ s/^$c\.?\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 544 | 33 | $c = decode_utf8('(č|Č)íslo'); | |||||||||||||||||||||||||||||||||||||||||
| 545 | 33 | $ret_series_ordinal =~ s/^$c\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 33 | $c = decode_utf8('(Výstava|Výst)'); | |||||||||||||||||||||||||||||||||||||||||
| 547 | 33 | $ret_series_ordinal =~ s/$c\.?\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 548 | 33 | $c = decode_utf8('(kniha|kn)'); | |||||||||||||||||||||||||||||||||||||||||
| 549 | 33 | $ret_series_ordinal =~ s/$c\.?\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 33 | $c = decode_utf8('(díl)'); | |||||||||||||||||||||||||||||||||||||||||
| 551 | 33 | $ret_series_ordinal =~ s/$c\.?\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 33 | $ret_series_ordinal =~ s/(vol)\.?\s*//ms; | |||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 33 | $ret_series_ordinal =~ s/(\d+),\s*(\d+)/$1-$2/ms; | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 33 | $ret_series_ordinal =~ s/^(\d+)\.$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | # Rename roman to arabic | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 33 | ▶ | if (isroman($ret_series_ordinal)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | $ret_series_ordinal = arabic($ret_series_ordinal); | |||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 33 | ▶ | if ($ret_series_ordinal =~ m/^(\d+)-(\d+)$/ms) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | my $first = $1; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 4 | my $second = $2; | |||||||||||||||||||||||||||||||||||||||||
| 566 | 4 | ▶ | if ($second < $first) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | my $first_len = length $first; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | my $second_len = length $second; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | my $first_addition = substr $first, 0, ($first_len - $second_len); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 3 | $ret_series_ordinal = $first.'-'.$first_addition.$second; | |||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | # XXX Remove all other characters. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 29 | $ret_series_ordinal =~ s/^(\d+).*$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 33 | return $ret_series_ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 91 | ▶ | sub clean_subtitle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_subtitle: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 91 | my $subtitle = shift; | |||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 91 | ▶ | if (! defined $subtitle) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 69 | return; | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | 22 | my $ret_subtitle = $subtitle; | |||||||||||||||||||||||||||||||||||||||||
| 588 | 22 | $ret_subtitle =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 589 | 22 | $ret_subtitle =~ s/\/$//g; | |||||||||||||||||||||||||||||||||||||||||
| 590 | 22 | $ret_subtitle =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 591 | 22 | $ret_subtitle =~ s/,$//g; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 22 | return $ret_subtitle; | |||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 32 | ▶ | sub clean_title { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_title: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 32 | my $title = shift; | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 32 | ▶ | if (! defined $title) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 32 | my $ret_title = $title; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 32 | $ret_title =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 605 | 32 | $ret_title =~ s/\s*\/$//g; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 32 | $ret_title =~ s/\s*\:$//g; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 32 | $ret_title =~ s/\.$//g; | |||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 32 | return $ret_title; | |||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | ▶ | sub look_for_external_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
look_for_external_id: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 3 | my ($object, $external_id_name, $deprecation_flag) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 3 | ▶ | $deprecation_flag ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$deprecation_flag ||= 0
MC/DC0%0/1
$deprecation_flag ||= 0
$deprecation_flag
Truth table50%1/2
A
A= $deprecation_flag
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 3 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 618 | 3 | foreach my $external_id (@{$object->external_ids}) { | |||||||||||||||||||||||||||||||||||||||||
| 619 | 6 | ▶ | if ($external_id->name eq $external_id_name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$external_id->name eq $external_id_name and $external_id->deprecated == $deprecation_flag
MC/DC50%1/2
$external_id->name eq $external_id_name and $external_id->deprecated == $deprecation_flag
$external_id->name eq $external_id_name
$external_id->deprecated == $deprecation_flag
Truth table66%2/3
A and B
A= $external_id->name eq $external_id_nameB= $external_id->deprecated == $deprecation_flag
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | && $external_id->deprecated == $deprecation_flag) { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | push @ret, $external_id->value; | |||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 3 | ▶ | return wantarray ? @ret : $ret[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 286 | ▶ | sub _remove_trailing_whitespace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_trailing_whitespace: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 286 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 286 | $string =~ s/^\s+//g; | |||||||||||||||||||||||||||||||||||||||||
| 633 | 286 | $string =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 286 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 178 | ▶ | sub _remove_square_brackets { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_square_brackets: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 178 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 178 | $string =~ s/^\[\s*(.*?)\s*\]$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 178 | $string =~ s/^\[\s*([^\]]+)$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 643 | 178 | $string =~ s/^([^\]]+)\s*\]$/$1/ms; | |||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | 178 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | 61 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | __END__ | ||||||||||||||||||||||||||||||||||||||||||