Thread Verzeichnisliste erstellen (7 answers)
Opened by Tom at 2011-09-24 14:38

hlubenow
 2011-09-25 12:21
#152656 #152656
User since
2009-02-22
875 Artikel
BenutzerIn
[default_avatar]
Wenn Du wissen willst, wie man sowas macht, hier mal ein Beispiel von Hand, also ohne (das natürlich empfehlenswerte) File::Find:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl

use warnings;
use strict;

use Cwd;

sub myfind {
    my $wd = shift;
    my @a = <$wd/*>;
    my @dirs = ();

    foreach my $i (@a) {
        if (-d $i) {
            push(@dirs, $i);
        }
    }

    foreach my $adir (@dirs) {
        print "$adir\n";
        myfind($adir);
    }
}

myfind(getcwd());

Das Geheimnis ist die Rekursion.

HTH
Last edited: 2011-09-25 12:22:38 +0200 (CEST)

View full thread Verzeichnisliste erstellen