From bee67f096a5732fed5cb9c3e716012b536950022 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 15 Jul 2023 19:16:01 +0200 Subject: [PATCH] get_user_status: fix stop_before_dest calculation --- lib/Travelynx.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 9c052e3..5b8680e 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -1446,10 +1446,18 @@ sub startup { = scalar @{ $ret->{route_after} } ? $ret->{route_after}[0][0] : undef; - my $stop_before_dest - = scalar @{ $ret->{route_after} } - ? $ret->{route_after}[-1][0] - : undef; + my $stop_before_dest; + for my $i ( 1 .. $#{ $ret->{route_after} } ) { + if ( $ret->{arr_name} + and $ret->{route_after}[$i][0] eq $ret->{arr_name} ) + { + $stop_before_dest = $ret->{route_after}[ $i - 1 ][0]; + last; + } + } + + say $stop_after_dep; + say $stop_before_dest; my ($dep_platform_number) = ( ( $ret->{dep_platform} // 0 ) =~ m{(\d+)} );