1 package SL::Helper::UNECERecommendation20;
7 use Exporter qw(import);
8 our @EXPORT_OK = qw(map_name_to_alpha_2_code);
10 use List::Util qw(first);
15 [ 'MTK', qr{^(?:m²|qm|quadrat *meter|quadrat *metre)$}i ],
18 [ 'CMT', qr{^(?:cm|centi *meter|centi *metre)$}i ],
19 [ 'MTR', qr{^(?:m|meter|metre)$}i ],
20 [ 'KMT', qr{^(?:km|kilo *meter|kilo *metre)$}i ],
23 [ 'SEC', qr{^(?:s|sec|second|sek|sekunde)$}i ],
24 [ 'MIN', qr{^min(?:ute)?$}i ],
25 [ 'HUR', qr{^(?:h(?:our)?|std(?:unde)?)$}i ],
26 [ 'DAY', qr{^(?:day|tag)$}i ],
27 [ 'MON', qr{^mon(?:th|at|atlich)?$}i ],
28 [ 'QAN', qr{^quart(?:er|al|alsweise)?$}i ],
29 [ 'ANN', qr{^(?:yearly|annually|jährlich|Jahr)?$}i ],
32 [ 'MGM', qr{^(?:mg|milli *gramm?)$}i ],
33 [ 'GRM', qr{^(?:g|gramm?)$}i ],
34 [ 'KGM', qr{^(?:kg|kilo *gramm?)$}i ],
35 [ 'KTN', qr{^(?:t|tonne|kilo *tonne)$}i ],
38 [ 'MLT', qr{^(?:ml|milli *liter|milli *litre)$}i ],
39 [ 'LTR', qr{^(?:l|liter|litre)$}i ],
42 [ 'C62', qr{^(?:stck|stück|pieces?|pc|psch|pauschal)$}i ],
45 sub map_name_to_code {
48 return undef if ($unit // '') eq '';
50 my $code = first { $unit =~ $_->[1] } @mappings;
51 return $code->[0] if $code;
54 $::lxdebug->message(LXDebug::WARN(), "UNECERecommendation20::map_name_code: no mapping found for '$unit'");