blob: b81184a9dd5806cd802240e7ec6d77435489d208 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
my $re_line = qr{
^
(?<acronym> [A-Z]{2}[A-Z ]{0,3} )
\s
(?<name> .+)
$
}x;
say <<'EOF';
package Travel::Status::DE::IRIS::Acronyms;
use strict;
use warnings;
use 5.018;
use utf8;
use List::MoreUtils qw(firstval);
our $VERSION = '0.00';
my @acronyms = (
EOF
while (my $line = <STDIN>) {
chomp $line;
if ($line =~ $re_line) {
my ($acronym, $name) = @+{qw{acronym name}};
$name =~ s{'}{\\'}g;
printf("\t['%s','%s'],\n", $acronym, $name);
}
}
say <<'EOF';
);
sub get_acronyms {
return @acronyms;
}
sub get_acronym_by_name {
my ( $name ) = @_;
my $nname = lc($name);
my $actual_match = firstval { $nname eq lc($_->[1]) } @acronyms;
if ($actual_match) {
return ($actual_match);
}
return ( grep { $_->[1] =~ m{$name}i } @acronyms );
}
1;
EOF
|