use warnings; use strict; my @a = qw(J K L M N O); my %done; for (my $i = 0; $i < @a; $i += 2){ my $str = $a[$i] . ' ' . $a[$i+1]; print $str, "\n"; $done{$str} = 1; }
In this case %done isn't really used, if you want each pair to be printed only once you can check if $done{$str} is already set.
In reply to Re: Adjacent Looping
by moritz
in thread Adjacent Looping
by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |