| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # vim: ts=4 sw=4 tw=78 et si: | 
| 2 |  |  |  |  |  |  | package Algorithm::CheckDigits; | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 15 |  |  | 15 |  | 336507 | use 5.006; | 
|  | 15 |  |  |  |  | 152 |  | 
| 5 | 15 |  |  | 15 |  | 80 | use strict; | 
|  | 15 |  |  |  |  | 30 |  | 
|  | 15 |  |  |  |  | 316 |  | 
| 6 | 15 |  |  | 15 |  | 102 | use warnings; | 
|  | 15 |  |  |  |  | 32 |  | 
|  | 15 |  |  |  |  | 366 |  | 
| 7 | 15 |  |  | 15 |  | 80 | use Carp; | 
|  | 15 |  |  |  |  | 29 |  | 
|  | 15 |  |  |  |  | 936 |  | 
| 8 | 15 |  |  | 15 |  | 96 | use vars qw($AUTOLOAD); | 
|  | 15 |  |  |  |  | 34 |  | 
|  | 15 |  |  |  |  | 2106 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | require Exporter; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our @ISA = qw(Exporter); | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | # Items to export into callers namespace by default. Note: do not export | 
| 15 |  |  |  |  |  |  | # names by default without a very good reason. Use EXPORT_OK instead. | 
| 16 |  |  |  |  |  |  | # Do not simply export all your public functions/methods/constants. | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # This allows declaration	use CheckDigits ':all'; | 
| 19 |  |  |  |  |  |  | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | 
| 20 |  |  |  |  |  |  | # will save memory. | 
| 21 |  |  |  |  |  |  | our %EXPORT_TAGS = ( | 
| 22 |  |  |  |  |  |  | 'all' => [ | 
| 23 |  |  |  |  |  |  | qw( | 
| 24 |  |  |  |  |  |  | CheckDigits method_descriptions method_list print_methods | 
| 25 |  |  |  |  |  |  | ) ] ); | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | our @EXPORT = qw( CheckDigits ); | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 15 |  |  | 15 |  | 6559 | use version; our $VERSION = qv('v1.3.6'); | 
|  | 15 |  |  |  |  | 28875 |  | 
|  | 15 |  |  |  |  | 82 |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | my %methods = ( | 
| 34 |  |  |  |  |  |  | 'upc'                => [ 'Algorithm::CheckDigits::MBase_001', | 
| 35 |  |  |  |  |  |  | 'Universal Product Code, UPC (US, CA)' ], | 
| 36 |  |  |  |  |  |  | 'blutbeutel'         => [ 'Algorithm::CheckDigits::MBase_002', | 
| 37 |  |  |  |  |  |  | 'Eurocode, blood bags' ], | 
| 38 |  |  |  |  |  |  | 'bzue_de'            => [ 'Algorithm::CheckDigits::MBase_002', | 
| 39 |  |  |  |  |  |  | 'Beleglose Zahlscheinüberweisung, BZÜ (DE)' ], | 
| 40 |  |  |  |  |  |  | 'ustid_de'           => [ 'Algorithm::CheckDigits::MBase_002', | 
| 41 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (DE)' ], | 
| 42 |  |  |  |  |  |  | 'sici'               => [ 'Algorithm::CheckDigits::MBase_003', | 
| 43 |  |  |  |  |  |  | 'Value Added Tax number, VAT (DE)' ], | 
| 44 |  |  |  |  |  |  | 'euronote'           => [ 'Algorithm::CheckDigits::M09_001', | 
| 45 |  |  |  |  |  |  | 'Euro bank notes, EUR' ], | 
| 46 |  |  |  |  |  |  | 'amex'               => [ 'Algorithm::CheckDigits::M10_001', | 
| 47 |  |  |  |  |  |  | 'American Express credit cards' ], | 
| 48 |  |  |  |  |  |  | 'bahncard'           => [ 'Algorithm::CheckDigits::M10_001', | 
| 49 |  |  |  |  |  |  | 'DB Bahncard (DE)' ], | 
| 50 |  |  |  |  |  |  | 'cusip'              => [ 'Algorithm::CheckDigits::M10_001', | 
| 51 |  |  |  |  |  |  | 'Committee on Uniform Security Identification Procedures, CUSIP (US)' ], | 
| 52 |  |  |  |  |  |  | 'diners'             => [ 'Algorithm::CheckDigits::M10_001', | 
| 53 |  |  |  |  |  |  | q(Diner's club credit cards) ], | 
| 54 |  |  |  |  |  |  | 'discover'           => [ 'Algorithm::CheckDigits::M10_001', | 
| 55 |  |  |  |  |  |  | 'Discover credit cards' ], | 
| 56 |  |  |  |  |  |  | 'enroute'            => [ 'Algorithm::CheckDigits::M10_001', | 
| 57 |  |  |  |  |  |  | 'EnRoute credit cards' ], | 
| 58 |  |  |  |  |  |  | 'eurocard'           => [ 'Algorithm::CheckDigits::M10_001', | 
| 59 |  |  |  |  |  |  | 'Eurocard credit cards' ], | 
| 60 |  |  |  |  |  |  | 'happydigits'        => [ 'Algorithm::CheckDigits::M10_001', | 
| 61 |  |  |  |  |  |  | 'Happy Digits (DE)' ], | 
| 62 |  |  |  |  |  |  | 'jcb'                => [ 'Algorithm::CheckDigits::M10_001', | 
| 63 |  |  |  |  |  |  | 'JCB credit cards' ], | 
| 64 |  |  |  |  |  |  | 'klubkarstadt'       => [ 'Algorithm::CheckDigits::M10_001', | 
| 65 |  |  |  |  |  |  | 'Klub Karstadt (DE)' ], | 
| 66 |  |  |  |  |  |  | 'mastercard'         => [ 'Algorithm::CheckDigits::M10_001', | 
| 67 |  |  |  |  |  |  | 'Mastercard credit cards' ], | 
| 68 |  |  |  |  |  |  | 'miles&more'         => [ 'Algorithm::CheckDigits::M10_001', | 
| 69 |  |  |  |  |  |  | 'Miles & More, Lufthansa (DE)' ], | 
| 70 |  |  |  |  |  |  | 'visa'               => [ 'Algorithm::CheckDigits::M10_001', | 
| 71 |  |  |  |  |  |  | 'VISA credit cards' ], | 
| 72 |  |  |  |  |  |  | 'isin'               => [ 'Algorithm::CheckDigits::M10_001', | 
| 73 |  |  |  |  |  |  | 'International Securities Identifikation Number, ISIN' ], | 
| 74 |  |  |  |  |  |  | 'imei'               => [ 'Algorithm::CheckDigits::M10_001', | 
| 75 |  |  |  |  |  |  | 'International Mobile Station Equipment Identity, IMEI' ], | 
| 76 |  |  |  |  |  |  | 'imeisv'             => [ 'Algorithm::CheckDigits::M10_001', | 
| 77 |  |  |  |  |  |  | 'International Mobile Station Equipment Identity and Software Version Number' ], | 
| 78 |  |  |  |  |  |  | 'siren'              => [ 'Algorithm::CheckDigits::M10_002', | 
| 79 |  |  |  |  |  |  | 'SIREN (FR)' ], | 
| 80 |  |  |  |  |  |  | 'siret'              => [ 'Algorithm::CheckDigits::M10_002', | 
| 81 |  |  |  |  |  |  | 'SIRET (FR)' ], | 
| 82 |  |  |  |  |  |  | 'ismn'               => [ 'Algorithm::CheckDigits::M10_003', | 
| 83 |  |  |  |  |  |  | 'International Standard Music Number, ISMN' ], | 
| 84 |  |  |  |  |  |  | 'ean'                => [ 'Algorithm::CheckDigits::M10_004', | 
| 85 |  |  |  |  |  |  | 'European Article Number, EAN' ], | 
| 86 |  |  |  |  |  |  | 'iln'                => [ 'Algorithm::CheckDigits::M10_004', | 
| 87 |  |  |  |  |  |  | 'Global Location Number, GLN' ], | 
| 88 |  |  |  |  |  |  | 'nve'                => [ 'Algorithm::CheckDigits::M10_004', | 
| 89 |  |  |  |  |  |  | 'Nummer der Versandeinheit, NVE, SSCC' ], | 
| 90 |  |  |  |  |  |  | '2aus5'              => [ 'Algorithm::CheckDigits::M10_004', | 
| 91 |  |  |  |  |  |  | '2 aus 5, 2 of 5, 2/5' ], | 
| 92 |  |  |  |  |  |  | 'isbn13'             => [ 'Algorithm::CheckDigits::M10_004', | 
| 93 |  |  |  |  |  |  | 'International Standard Book Number, ISBN13' ], | 
| 94 |  |  |  |  |  |  | 'identcode_dp'       => [ 'Algorithm::CheckDigits::M10_005', | 
| 95 |  |  |  |  |  |  | 'Identcode Deutsche Post AG (DE)' ], | 
| 96 |  |  |  |  |  |  | 'leitcode_dp'        => [ 'Algorithm::CheckDigits::M10_005', | 
| 97 |  |  |  |  |  |  | 'Leitcode Deutsche Post AG (DE)' ], | 
| 98 |  |  |  |  |  |  | 'rentenversicherung' => [ 'Algorithm::CheckDigits::M10_006', | 
| 99 |  |  |  |  |  |  | 'Rentenversicherungsnummer, VSNR (DE)' ], | 
| 100 |  |  |  |  |  |  | 'sedol'              => [ 'Algorithm::CheckDigits::M10_008', | 
| 101 |  |  |  |  |  |  | 'Stock Exchange Daily Official List, SEDOL (GB)' ], | 
| 102 |  |  |  |  |  |  | 'betriebsnummer'     => [ 'Algorithm::CheckDigits::M10_009', | 
| 103 |  |  |  |  |  |  | 'Betriebsnummer (DE)' ], | 
| 104 |  |  |  |  |  |  | 'postcheckkonti'     => [ 'Algorithm::CheckDigits::M10_010', | 
| 105 |  |  |  |  |  |  | 'Postscheckkonti (CH)' ], | 
| 106 |  |  |  |  |  |  | 'ups'                => [ 'Algorithm::CheckDigits::M10_011', | 
| 107 |  |  |  |  |  |  | 'United Parcel Service, UPS' ], | 
| 108 |  |  |  |  |  |  | 'isbn'               => [ 'Algorithm::CheckDigits::M11_001', | 
| 109 |  |  |  |  |  |  | 'International Standard Book Number, ISBN10' ], | 
| 110 |  |  |  |  |  |  | 'issn'               => [ 'Algorithm::CheckDigits::M11_001', | 
| 111 |  |  |  |  |  |  | 'International Standard Serial Number, ISSN' ], | 
| 112 |  |  |  |  |  |  | 'ustid_pt'           => [ 'Algorithm::CheckDigits::M11_001', | 
| 113 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (PT)' ], | 
| 114 |  |  |  |  |  |  | 'vatrn_pt'           => [ 'Algorithm::CheckDigits::M11_001', | 
| 115 |  |  |  |  |  |  | 'Value Added Tax number, VAT (PT)' ], | 
| 116 |  |  |  |  |  |  | 'hkid'               => [ 'Algorithm::CheckDigits::M11_001', | 
| 117 |  |  |  |  |  |  | 'Hong Kong Identity Card, HKID (HK)' ], | 
| 118 |  |  |  |  |  |  | 'wagonnr_br'         => [ 'Algorithm::CheckDigits::M11_001', | 
| 119 |  |  |  |  |  |  | 'Codificação dos vagões (BR)' ], | 
| 120 |  |  |  |  |  |  | 'nhs_gb'             => [ 'Algorithm::CheckDigits::M11_001', | 
| 121 |  |  |  |  |  |  | 'National Health Service, NHS (GB)' ], | 
| 122 |  |  |  |  |  |  | 'vat_sl'             => [ 'Algorithm::CheckDigits::M11_001', | 
| 123 |  |  |  |  |  |  | 'Value Added Tax number, VAT (SL)' ], | 
| 124 |  |  |  |  |  |  | 'pzn'                => [ 'Algorithm::CheckDigits::M11_002', | 
| 125 |  |  |  |  |  |  | 'Pharmazentralnummer (DE)' ], | 
| 126 |  |  |  |  |  |  | 'pkz'                => [ 'Algorithm::CheckDigits::M11_003', | 
| 127 |  |  |  |  |  |  | 'Personenkennzahl der DDR' ], | 
| 128 |  |  |  |  |  |  | 'cpf'                => [ 'Algorithm::CheckDigits::M11_004', | 
| 129 |  |  |  |  |  |  | 'Cadastro de Pessoas Físicas, CPF (BR)' ], | 
| 130 |  |  |  |  |  |  | 'titulo_eleitor'     => [ 'Algorithm::CheckDigits::M11_004', | 
| 131 |  |  |  |  |  |  | 'Título Eleitoral (BR)' ], | 
| 132 |  |  |  |  |  |  | 'ccc_es'             => [ 'Algorithm::CheckDigits::M11_006', | 
| 133 |  |  |  |  |  |  | 'Código de Cuenta Corriente, CCC (ES)' ], | 
| 134 |  |  |  |  |  |  | 'ustid_fi'           => [ 'Algorithm::CheckDigits::M11_007', | 
| 135 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (FI)' ], | 
| 136 |  |  |  |  |  |  | 'vatrn_fi'           => [ 'Algorithm::CheckDigits::M11_007', | 
| 137 |  |  |  |  |  |  | 'Value Added Tax number, VAT (FI)' ], | 
| 138 |  |  |  |  |  |  | 'ustid_dk'           => [ 'Algorithm::CheckDigits::M11_008', | 
| 139 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (DK)' ], | 
| 140 |  |  |  |  |  |  | 'vatrn_dk'           => [ 'Algorithm::CheckDigits::M11_008', | 
| 141 |  |  |  |  |  |  | 'Value Added Tax number, VAT (DK)' ], | 
| 142 |  |  |  |  |  |  | 'nric_sg'            => [ 'Algorithm::CheckDigits::M11_009', | 
| 143 |  |  |  |  |  |  | 'National Registration Identity Card, NRIC (SG)' ], | 
| 144 |  |  |  |  |  |  | 'ahv_ch'             => [ 'Algorithm::CheckDigits::M11_010', | 
| 145 |  |  |  |  |  |  | 'Alters- und Hinterlassenenversicherungsnummer, AHV (CH)' ], | 
| 146 |  |  |  |  |  |  | 'ustid_nl'           => [ 'Algorithm::CheckDigits::M11_011', | 
| 147 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (NL)' ], | 
| 148 |  |  |  |  |  |  | 'vatrn_nl'           => [ 'Algorithm::CheckDigits::M11_011', | 
| 149 |  |  |  |  |  |  | 'Value Added Tax number, VAT (NL)' ], | 
| 150 |  |  |  |  |  |  | 'bwpk_de'            => [ 'Algorithm::CheckDigits::M11_012', | 
| 151 |  |  |  |  |  |  | 'Personenkennummer der Bundeswehr (DE)' ], | 
| 152 |  |  |  |  |  |  | 'ustid_gr'           => [ 'Algorithm::CheckDigits::M11_013', | 
| 153 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (GR)' ], | 
| 154 |  |  |  |  |  |  | 'vatrn_gr'           => [ 'Algorithm::CheckDigits::M11_013', | 
| 155 |  |  |  |  |  |  | 'Value Added Tax number, VAT (GR)' ], | 
| 156 |  |  |  |  |  |  | 'esr5_ch'            => [ 'Algorithm::CheckDigits::M11_015', | 
| 157 |  |  |  |  |  |  | 'Einzahlungsschein mit Referenz, ESR5 (CH)' ], | 
| 158 |  |  |  |  |  |  | 'ustid_pl'           => [ 'Algorithm::CheckDigits::M11_016', | 
| 159 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (PL)' ], | 
| 160 |  |  |  |  |  |  | 'vatrn_pl'           => [ 'Algorithm::CheckDigits::M11_016', | 
| 161 |  |  |  |  |  |  | 'Value Added Tax number, VAT (PL)' ], | 
| 162 |  |  |  |  |  |  | 'nip'                => [ 'Algorithm::CheckDigits::M11_016', | 
| 163 |  |  |  |  |  |  | 'numer identyfikacji podatkowej, NIP' ], | 
| 164 |  |  |  |  |  |  | 'ecno'               => [ 'Algorithm::CheckDigits::M11_017', | 
| 165 |  |  |  |  |  |  | 'European Commission number, EC-No (for chemicals)' ], | 
| 166 |  |  |  |  |  |  | 'einecs'             => [ 'Algorithm::CheckDigits::M11_017', | 
| 167 |  |  |  |  |  |  | 'European Inventory of Existing Commercial Chemical Substances, EINECS' ], | 
| 168 |  |  |  |  |  |  | 'elincs'             => [ 'Algorithm::CheckDigits::M11_017', | 
| 169 |  |  |  |  |  |  | 'European List of Notified Chemical Substances, ELINCS' ], | 
| 170 |  |  |  |  |  |  | 'isan'               => [ 'Algorithm::CheckDigits::M16_001', | 
| 171 |  |  |  |  |  |  | 'International Standard Audiovisual Number, ISAN' ], | 
| 172 |  |  |  |  |  |  | 'dni_es'             => [ 'Algorithm::CheckDigits::M23_001', | 
| 173 |  |  |  |  |  |  | 'Documento nacional de identidad (ES)' ], | 
| 174 |  |  |  |  |  |  | 'ustid_ie'           => [ 'Algorithm::CheckDigits::M23_002', | 
| 175 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (IE)' ], | 
| 176 |  |  |  |  |  |  | 'vatrn_ie'           => [ 'Algorithm::CheckDigits::M23_002', | 
| 177 |  |  |  |  |  |  | 'Value Added Tax number, VAT (IE)' ], | 
| 178 |  |  |  |  |  |  | 'tin_ie'             => [ 'Algorithm::CheckDigits::M23_002', | 
| 179 |  |  |  |  |  |  | 'Tax Identification Number (IE)' ], | 
| 180 |  |  |  |  |  |  | 'code_39'            => [ 'Algorithm::CheckDigits::M43_001', | 
| 181 |  |  |  |  |  |  | 'Code39, 3 of 9' ], | 
| 182 |  |  |  |  |  |  | 'ustid_lu'           => [ 'Algorithm::CheckDigits::M89_001', | 
| 183 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (LU)' ], | 
| 184 |  |  |  |  |  |  | 'vatrn_lu'           => [ 'Algorithm::CheckDigits::M89_001', | 
| 185 |  |  |  |  |  |  | 'Value Added Tax number, VAT (LU)' ], | 
| 186 |  |  |  |  |  |  | 'ustid_be'           => [ 'Algorithm::CheckDigits::M97_001', | 
| 187 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (BE)' ], | 
| 188 |  |  |  |  |  |  | 'vatrn_be'           => [ 'Algorithm::CheckDigits::M97_001', | 
| 189 |  |  |  |  |  |  | 'Value Added Tax number, VAT (BE)' ], | 
| 190 |  |  |  |  |  |  | 'iban'               => [ 'Algorithm::CheckDigits::M97_002', | 
| 191 |  |  |  |  |  |  | 'International Bank Account Number (IBAN)' ], | 
| 192 |  |  |  |  |  |  | 'pa_de'              => [ 'Algorithm::CheckDigits::MXX_001', | 
| 193 |  |  |  |  |  |  | 'Personalausweis (DE)' ], | 
| 194 |  |  |  |  |  |  | 'aba_rn'             => [ 'Algorithm::CheckDigits::MXX_001', | 
| 195 |  |  |  |  |  |  | 'American Bankers Association routing number (ABA RN)' ], | 
| 196 |  |  |  |  |  |  | 'cas'                => [ 'Algorithm::CheckDigits::MXX_002', | 
| 197 |  |  |  |  |  |  | 'Chemical abstract service, CAS' ], | 
| 198 |  |  |  |  |  |  | 'dem'                => [ 'Algorithm::CheckDigits::MXX_003', | 
| 199 |  |  |  |  |  |  | 'Deutsche Mark Banknoten, DEM' ], | 
| 200 |  |  |  |  |  |  | 'ustid_at'           => [ 'Algorithm::CheckDigits::MXX_004', | 
| 201 |  |  |  |  |  |  | 'Umsatzsteuer-Identifikationsnummer (AT)' ], | 
| 202 |  |  |  |  |  |  | 'vatrn_at'           => [ 'Algorithm::CheckDigits::MXX_004', | 
| 203 |  |  |  |  |  |  | 'Value Added Tax number, VAT (AT)' ], | 
| 204 |  |  |  |  |  |  | 'esr9_ch'            => [ 'Algorithm::CheckDigits::MXX_005', | 
| 205 |  |  |  |  |  |  | 'Einzahlungsschein mit Referenz, ESR9 (CH)' ], | 
| 206 |  |  |  |  |  |  | 'verhoeff'           => [ 'Algorithm::CheckDigits::MXX_006', | 
| 207 |  |  |  |  |  |  | 'Verhoeff scheme' ], | 
| 208 |  |  |  |  |  |  | ); | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | sub CheckDigits { | 
| 211 | 110 |  | 50 | 110 | 1 | 7685 | my $method = shift || ''; | 
| 212 |  |  |  |  |  |  |  | 
| 213 | 110 | 50 |  |  |  | 437 | if ( my $pkg = $methods{ lc($method) } ) { | 
| 214 | 110 |  |  |  |  | 213 | my $module = $pkg->[0]; | 
| 215 | 110 |  |  |  |  | 199 | my $file   = $pkg->[0]; | 
| 216 | 110 |  |  |  |  | 540 | $file =~ s{::}{/}g; | 
| 217 | 110 |  |  |  |  | 23511 | require "$file.pm"; | 
| 218 | 110 |  |  |  |  | 558 | return new $module($method); | 
| 219 |  |  |  |  |  |  | } | 
| 220 |  |  |  |  |  |  | else { | 
| 221 | 0 |  |  |  |  | 0 | die "Don't know checkdigit algorithm for '$method'!"; | 
| 222 |  |  |  |  |  |  | } | 
| 223 |  |  |  |  |  |  | }    # CheckDigits() | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | sub method_list { | 
| 226 | 0 |  |  | 0 | 1 | 0 | my @methods = (); | 
| 227 | 0 |  |  |  |  | 0 | foreach my $method ( sort keys %methods ) { | 
| 228 | 0 |  |  |  |  | 0 | push @methods, $method; | 
| 229 |  |  |  |  |  |  | } | 
| 230 | 0 | 0 |  |  |  | 0 | return wantarray ? @methods : \@methods; | 
| 231 |  |  |  |  |  |  | }    # method_list() | 
| 232 |  |  |  |  |  |  |  | 
| 233 |  |  |  |  |  |  | sub method_descriptions { | 
| 234 | 0 |  |  | 0 | 1 | 0 | my @meths = @_; | 
| 235 | 0 | 0 |  |  |  | 0 | if ($meths[0] eq 'Algorithm::CheckDigits') { | 
| 236 |  |  |  |  |  |  | # it was called Algorithm::CheckDigits->method_descriptions | 
| 237 | 0 |  |  |  |  | 0 | shift @meths; | 
| 238 |  |  |  |  |  |  | } | 
| 239 | 0 | 0 |  |  |  | 0 | if (0 == scalar @meths) { | 
| 240 | 0 |  |  |  |  | 0 | @meths = keys %methods; | 
| 241 |  |  |  |  |  |  | } | 
| 242 | 0 | 0 |  |  |  | 0 | my %descr = map { $_ => ($methods{$_}) ? $methods{$_}->[1] | 
|  | 0 |  |  |  |  | 0 |  | 
| 243 |  |  |  |  |  |  | :                   'unknown'         } @meths; | 
| 244 | 0 | 0 |  |  |  | 0 | return wantarray ? %descr : \%descr; | 
| 245 |  |  |  |  |  |  | } # method_descriptions() | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | sub plug_in { | 
| 248 | 9 | 100 |  | 9 | 1 | 1528 | if ('Algorithm::CheckDigits' eq $_[0]) { | 
| 249 | 3 |  |  |  |  | 6 | shift; | 
| 250 |  |  |  |  |  |  | } | 
| 251 | 9 |  | 50 |  |  | 25 | my $module = shift || | 
| 252 |  |  |  |  |  |  | die "you need to specify a module except 'Algorithm::CheckDigits'"; | 
| 253 | 9 |  | 33 |  |  | 19 | my $descr  = shift || "algorithm of module $module"; | 
| 254 | 9 |  | 50 |  |  | 27 | my $key    = lc shift || 'plalg'; | 
| 255 | 9 | 100 |  |  |  | 21 | if (exists $methods{$key}) { | 
| 256 | 2 |  |  |  |  | 4 | $key .= ',1'; | 
| 257 |  |  |  |  |  |  | } | 
| 258 | 9 |  |  |  |  | 19 | while (exists $methods{$key}) { | 
| 259 | 1 |  |  |  |  | 9 | $key =~ s/(\d+)$/my $y = $1; ++$y/e; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 4 |  | 
| 260 |  |  |  |  |  |  | } | 
| 261 | 9 |  |  |  |  | 20 | $methods{$key} = [ $module, $descr ]; | 
| 262 | 9 |  |  |  |  | 23 | return $key; | 
| 263 |  |  |  |  |  |  | } # plug_in() | 
| 264 |  |  |  |  |  |  |  | 
| 265 |  |  |  |  |  |  | sub print_methods { | 
| 266 | 0 |  |  | 0 | 1 |  | foreach my $method ( sort keys %methods ) { | 
| 267 | 0 |  |  |  |  |  | print "$method => $methods{$method}\n"; | 
| 268 |  |  |  |  |  |  | } | 
| 269 |  |  |  |  |  |  | }    # print_methods() | 
| 270 |  |  |  |  |  |  |  | 
| 271 |  |  |  |  |  |  | sub AUTOLOAD { | 
| 272 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 273 | 0 |  |  |  |  |  | my $attr = $AUTOLOAD; | 
| 274 | 0 | 0 |  |  |  |  | unless ( $attr =~ /^Algorithm::CheckDigits::[A-Za-z_0-9]*$/ ) { | 
| 275 | 0 |  |  |  |  |  | croak "$attr is not defined"; | 
| 276 |  |  |  |  |  |  | } | 
| 277 | 0 |  |  |  |  |  | return ''; | 
| 278 |  |  |  |  |  |  | }    # AUTOLOAD() | 
| 279 |  |  |  |  |  |  |  | 
| 280 |  |  |  | 0 |  |  | sub DESTROY { | 
| 281 |  |  |  |  |  |  | } | 
| 282 |  |  |  |  |  |  |  | 
| 283 |  |  |  |  |  |  | # Preloaded methods go here. | 
| 284 |  |  |  |  |  |  |  | 
| 285 |  |  |  |  |  |  | 1; | 
| 286 |  |  |  |  |  |  | __END__ |