# fetch directories my @dirs = do{ local $/ = undef; split /\n/, ; }; # mischen fisher_yates_shuffle( \@dirs ); # sortieren @dirs = sort{ weight($a) <=> weight($b) } @dirs; while( my $e = shift @dirs ){ print "$e\n"; } # perlfaq4 sub fisher_yates_shuffle { my $deck = shift; # $deck is a reference to an array return unless @$deck; # must not be empty! my $i = @$deck; while (--$i) { my $j = int rand ($i+1); @$deck[$i,$j] = @$deck[$j,$i]; } } # bewerten sub weight{ my $path = shift; my @p = split /\//, $path; my $score = 0; for( my $i = 0; $i < scalar @p; $i++){ $score += ord($p[$i]) * 2 ** $i; } return $score; } __DATA__ / /abc/ /abc/test/ /abc/test/z.php4 /abc/test/z.txt /asdf/ /asdf/123/ /asdf/A/ /asdf/B/ /asdf/B/C/ /asdf/B/C/a.file /home/ /home/test/ /home/test/asdf/ /home/test/asdf/jklo/ /home/test/asdf/jklo/rstuv2/ /home/test/asdf/jklo/rstuvw11/ /root/config /root/tmp/