A very elegant and general solution: use Algorithm::Combinatorics qw/.../;
For example:
use Algorithm::Combinatorics qw/combinations/; @names = ('rita', 'sue','bob', 'daisy'); my $r=combinations(\@names,2); while(my $res=$r->next){ print "@$res\n"; }
There are several other combinatorical functions to replace all these foreach loops...
In reply to Re: foreach loops
by dokkeldepper
in thread foreach loops
by richill
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |