in reply to Consecutive if loops
I think the logic you want is:
if ($start_input =~ /\d\d\d\d\.\d\d/ && $end_input =~ /\d\d\d\d\.\d\d/ +) { ...; } elsif ($start_input =~ /\d\d\d\d/ && $end_input =~ /\d\d\d\d/) { ...; }
This is because you've got two conditionals which overlap. Test specific conditions before generic ones. Compare:
use v5.12; my $name = "Toby"; { say "FIRST BLOCK"; if ($name =~ /^T/) { say "name starts with T" } elsif ($name =~ /^Toby/) { say "name is Toby" } say "END BLOCK"; } { say "SECOND BLOCK"; if ($name =~ /^Toby/) { say "name is Toby" } elsif ($name =~ /^T/) { say "name starts with T" } say "END BLOCK"; }
The "name starts with T" test is more generic than the "name is Toby" test, so if you perform the "name starts with T" test first, it will effectively swallow up the other test.
|
|---|