summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/IRIS/Stations.pm.PL
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-08-14 09:56:16 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-08-14 09:56:16 +0200
commitf8afc7698642079438925ecc3b8562ea4be6399d (patch)
tree38070012648000b2d0481ea3b95fd450a882725f /lib/Travel/Status/DE/IRIS/Stations.pm.PL
parentdd99f577630a354c9fd47377592e94532dd1483b (diff)
Stations: Short-circuit when receiving an invalid station name/code
This avoids thousands of "uninitialized value" warnings
Diffstat (limited to 'lib/Travel/Status/DE/IRIS/Stations.pm.PL')
-rw-r--r--lib/Travel/Status/DE/IRIS/Stations.pm.PL8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Travel/Status/DE/IRIS/Stations.pm.PL b/lib/Travel/Status/DE/IRIS/Stations.pm.PL
index c21c94e..c2681ab 100644
--- a/lib/Travel/Status/DE/IRIS/Stations.pm.PL
+++ b/lib/Travel/Status/DE/IRIS/Stations.pm.PL
@@ -80,6 +80,10 @@ sub normalize {
sub get_station {
my ($name) = @_;
+ if (not $name) {
+ return;
+ }
+
my $ds100_match = firstval { $name eq $_->[0] } @stations;
if ($ds100_match) {
@@ -125,6 +129,10 @@ sub get_station_by_location {
sub get_station_by_name {
my ($name) = @_;
+ if (not $name) {
+ return;
+ }
+
my $nname = lc($name);
my $actual_match = firstval { $nname eq lc( $_->[1] ) } @stations;