I am trying to run a loop which ends after it satisfies the If for the first time. I read that you are supposed to use the last command, similar to Break in C#. Can someone perhaps explain why the last is being ignored in this code, and where it should go. THanks!
for (my $i=0; $i < $#UndlyPx; $i++) {
if ($TheoPrice < $UndlyPx[$i]) {
print $UndlyPx[$i - 1] . "\n";
print $UndlyPx[$i] . "\n";
last;
}
}
}
close(FILE);
for (my $i=0; $i < $#UndlyPx; $i++) {
if ($TheoPrice < $UndlyPx[$i]) {
print $UndlyPx[$i - 1] . "\n";
print $UndlyPx[$i] . "\n";
last;
}
}
}
close(FILE);