in reply to For loop abortions
Perhaps it could be made even simpler, but I don't understand well enough what you intend to do to be able to suggest something that might get rid of one of the loops variables.for my $i (0..$#sig) { for my $j ($i+1..$#sig) { print "$sig[$j]\n"; } }
Update: Another possible way:
second update: fixed an off-by-one error in the first piece of code. Thanks to AnomalousMonk for pointing it out.for my $i (0..$#sig) { for my $item (@sig[$i+1..$#sig]) { print "$item\n"; } }
third update: fixed yet another an off-by-one error . Thanks to AnomalousMonk for pointing it out.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: For loop abortions
by AnomalousMonk (Archbishop) on Mar 18, 2016 at 12:34 UTC | |
by Laurent_R (Canon) on Mar 18, 2016 at 18:34 UTC |