From 49197e9b490f2e2da4747b28889defdb4b87451d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Dec 2016 14:11:37 +0100 Subject: line no calculation: Don't get confused by 3- or 4-digit train numbers --- lib/Travel/Status/DE/IRIS/Result.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Travel/Status/DE') diff --git a/lib/Travel/Status/DE/IRIS/Result.pm b/lib/Travel/Status/DE/IRIS/Result.pm index 847682f..5a4247c 100644 --- a/lib/Travel/Status/DE/IRIS/Result.pm +++ b/lib/Travel/Status/DE/IRIS/Result.pm @@ -202,8 +202,8 @@ sub new { $ref->{is_cancelled} = 0; - if ( not defined $ref->{line_no} ) { - my $train_prefix = substr( $ref->{train_no}, 0, 3 ); + if ( not defined $ref->{line_no} and length( $ref->{train_no} ) > 2 ) { + my $train_prefix = substr( $ref->{train_no}, -5, 3 ); $ref->{line_no} = $linemap{ $ref->{type} }{$train_prefix}; } -- cgit v1.2.3