summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-01-02 05:36:27 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-01-02 05:36:27 +0100
commit67480fdbb5e465f3ac9f51278030ef35534b8ac7 (patch)
tree740393fed4b8571c56e6b12613d377ca42c7ac94
parent235f0b5090731e41c53654e4d3332d822a018c77 (diff)
acronyms: Add get_acronym_by_name
-rw-r--r--lib/Travel/Status/DE/IRIS/Acronyms.pm17
-rwxr-xr-xscripts/acronyms.pl17
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/Travel/Status/DE/IRIS/Acronyms.pm b/lib/Travel/Status/DE/IRIS/Acronyms.pm
index 5c6c10c..59bdad7 100644
--- a/lib/Travel/Status/DE/IRIS/Acronyms.pm
+++ b/lib/Travel/Status/DE/IRIS/Acronyms.pm
@@ -2,9 +2,11 @@ package Travel::Status::DE::IRIS::Acronyms;
use strict;
use warnings;
-use 5.010;
+use 5.018;
use utf8;
+use List::MoreUtils qw(firstval);
+
our $VERSION = '0.00';
my @acronyms = (
@@ -15098,5 +15100,18 @@ 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;
diff --git a/scripts/acronyms.pl b/scripts/acronyms.pl
index d78afad..b81184a 100755
--- a/scripts/acronyms.pl
+++ b/scripts/acronyms.pl
@@ -17,9 +17,11 @@ package Travel::Status::DE::IRIS::Acronyms;
use strict;
use warnings;
-use 5.010;
+use 5.018;
use utf8;
+use List::MoreUtils qw(firstval);
+
our $VERSION = '0.00';
my @acronyms = (
@@ -43,5 +45,18 @@ 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