Hi.. I'm trying to get file stats off various networked data volumes, and I've been using opendir and readdir... however, it takes ages for anything not on the current segment. Someone has suggested using File::Find instead, but the (to my eyes) meagre documentation doesn't give me ay clues... could someone point me in the right place?... I've included the main snippets of rough code so you can see what I'm trying to do... (P.S. this is for NT/Netware systems, so cdate actually gives me creation date)
many thanks
Phil DG
Main code here
.
.
.
pathstat($pathname, $file_count, $dir_count, $total_size, $aged_fil
+e_count, $aged_total_size);
print "\n\nFile Statistics for $pathname\n".
"\ntotal file count is $file_count\n".
"total dir count is $dir_count\n".
"total size is $total_size\n\n".
"number of files between $lowrange and $highrange days old is
+ $aged_file_count\n".
"total size of aged files is $aged_total_size\n";
.
.
.
sub pathstat {
my($arg_pathname) = $_[0];
my($dir_entry);
my($dir_handle) = "BIN" . $_[2];
my($file_age);
my($file_size);
opendir($dir_handle, $arg_pathname) or die "Can't open $arg_pathnam
+e: $!";
while (defined($dir_entry = readdir $dir_handle)) {
if (-d $arg_pathname . "\\" . $dir_entry) {
if ($dir_entry ne "." && $dir_entry ne "..") {
++$_[2];
pathstat($arg_pathname . "\\" . $dir_entry, $_[1], $_[2],
+$_[3], $_[4], $_[5]);
}
} else {
++$_[1];
$file_size = (-s $arg_pathname . "\\" . $dir_entry);
$_[3] += $file_size;
$file_age = (-C $arg_pathname . "\\" . $dir_entry);
if ($file_age >= $lowrange && $file_age <= $highrange) {
++$_[4];
$_[5] += $file_size;
}
}
}
closedir($dir_handle);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.