Thread readdir sort und überhaupt Probleme (6 answers)
Opened by Alexander at 2012-02-21 17:13

Alexander
 2012-02-24 22:07
#156416 #156416
User since
2012-02-21
25 Artikel
BenutzerIn
[default_avatar]
Danke derweil einmal, habe es geschafft die leeren Verzeichnisse auszublenden und aud die .File und ..File nicht zu beachten

Mein Problem ist nun, dass die Filegröße mit stat() nicht angzeigt wird.
Es sollte alles vorweigend jedoch Verzeichnisse im Verzeichnis nur als ausgelssen angezeigt werden.

Leider hat kein File eine "Größe" bzw. wird keine Größe zurückgegeben.

Ich verwende win 7 32 bit mit sp1

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! c:/perl/bin/perl.exe 
use strict;
print "\nPlease put in the folder you want to search for files, like example underneath\n";
print "Example for windows 'c:/.../.../.../': ";
chomp(my $dirname = <STDIN>);
opendir (DIR, $dirname) or die "\nError $!\n";  #opens the directory or brings back an error
while (my $name = readdir DIR) {
        next if $name =~ /^\./;                 #excludes the Files . and .. from the list
        my @attr = stat($name);
        if ($attr[7] <= 0) {
        print "Oimitting Directory $name\n";
        } else {
        my $mtime = localtime($attr[9]);
        print "$name  $attr[7] bytes  modified: $mtime\n";
        }}
closedir DIR;

View full thread readdir sort und überhaupt Probleme