It somehow doesn't print the desired result like this:# Number of elements in the array are always EVEN my @arr = qw (J K L M N O); my %done; OUT: foreach my $elem(@arr) { IN: foreach my $elem2(@arr) { next IN if ($elem eq $elem2); next IN if ($done{$elem2." - ". $elem}); print "$elem - $elem2\n"; $done{$elem." - ".$elem2} = 1; } }
What's wrong with my script above?J - K L - M N - O
In reply to Adjacent Looping by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |