From f8afc7698642079438925ecc3b8562ea4be6399d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 14 Aug 2021 09:56:16 +0200 Subject: Stations: Short-circuit when receiving an invalid station name/code This avoids thousands of "uninitialized value" warnings --- lib/Travel/Status/DE/IRIS/Stations.pm.PL | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/Travel') 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; -- cgit v1.2.3