[Perl]

ElGecko

Ensign
Registriert
Aug. 2004
Beiträge
143
Morgen,

ich sol ein Script schreiben, welches nur die Ordner eines Verzeichnis auflistet. Das Verzeichnis, indem sich die Ordner befinden, möchte ich dabei über eine Variable übergeben. Dies soll mit File::Find möglich sein, habe dazu aber noch ncihts brauchbares gefunden :( Hoffe, hier kann mir jmd weiterhelfen

Greetz, Gecko
 
Hab die SelfHTML Seite auch schon besucht und bin daran verzweifelt, insbeondere an File::Find!!!
 
Tja das kenn ich bei Perl :king:

Google doch mal, das hier hab ich z.b. gefunden, vielleicht hilfts!?

Code:
#!/bin/perl

 use File::Find;

 my $ByteCount=0;

 # Issue the find command passing two arguments

 # The first argument is the subroutine that will be called for each file in the path.

 # The second argument is the directory to start your search in.

 find(\&cleanup, "c:\\");

 print "Files are using $ByteCount bytes\n";

 # Subroutine that determines whether we matched the file extensions.

 sub cleanup {
   if ((/\.zip$/) || (/\.tmp$/) || (/\.TMP$/) || (/^~/) || (/\.chk$/) ){
      print "$File::Find::name\n";
          # Only piece of information we care about is the $size, which is in bytes.
         my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $therest) = stat($_) or die "Unable to stat $_\n";
         $ByteCount += $size;
   }

 }
 
Zurück
Oben