in reply to Re^5: loop surprise
in thread loop surprise
But what I was trying to do is to find the smallest number in a certain range satisfying some condition and then go on using that found value.
Doing it like
Looked (at the time) to be a straightforward solution and I was suprised that it did not work.my $i; for $i (1..10) { last if &condition($i); } &do_more_stuff_with_the_value_found($i);
This is just for explaining where this comes from (I am not a really good programmer I am afraid...)
And even accepting that this is not the way to do it (there are of course many other ways), it is neverthless surprising that this actually does work:
This is to my eyes at least an inconsistency (and thus a wart). But whatever, this is how it was, is and will be...my $i; for ($i=1; $i<=10; $i) { last if &condition($i); } &do_more_stuff_with_the_value_found($i);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: loop surprise
by Your Mother (Archbishop) on Apr 04, 2018 at 00:38 UTC | |
|
Re^7: loop surprise
by Skeeve (Parson) on Apr 04, 2018 at 10:02 UTC | |
by Marshall (Canon) on Apr 04, 2018 at 17:59 UTC | |
|
Re^7: loop surprise
by BillKSmith (Monsignor) on Apr 04, 2018 at 04:18 UTC |