#!/usr/bin/perl use strict; use warnings; my @hand = qw(a b c d); # Liste mit den Ergebnissen my @ch; # gehe die POSITIONEN in der Hand durch for my $p (0..$#hand) { # füge die Position in @ch ein push(@ch,[$p]); # gehe alle Elemnte in @ch durch for my $elm (@ch) { # hole die Liste aus @$lem # ist eine Kopie my @l=@$elm; # schaue in der Liste nach, ob die Position schon drin ist unless(grep{$p==$_}@l) { # füge die Position zur Liste hinzu push(@l,$p); # sortiere es # ist dann später übersichtlicher :-) @l=sort(@l); #füge diese Kombination als neue hinzu push (@ch, \@l); } } } ############## #Ausgabe: #### ############## # gehe alles durch for my $c (@ch) { # gehe die einzelne Kombination durch for my $cc (@$c) { print $hand[$cc]." "; } print "\n"; }