Hi,
probably something like this:
#!/usr/bin/perl use strict; use warnings; use 5.010; my @list = qw(PA5098 PA5100 PA5092 PA3175); for (my $i = 0; $i < @list - 1; $i++) { for (my $j = $i + 1; $j < @list; $j++) { my $diff = $j - $i; print "$list[$i] $list[$j] $diff\n"; } }
Be aware: You need a special case when list has less than two elements.
Regards
McA
In reply to Re: problem with loop
by McA
in thread problem with loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |