[email protected] (Jim Gibson) writes:
[...]
> I don’t see how the code you have posted can possibly produce the
> output you have reported. The code above looks like error checking
> that the user of the program has entered one argument, and that
> argument is the name of a directory.
Egad, sometimes I scare myself being so bone headed.
All the crude that got posted used to reside on my script. I cut it
off and made a few small changes to the script so no arguments were
needed and though I had pasted the the rest here... (it appears below)
In stead pasting the cut off part.
But at least I did have the wisdom to save the script and date it as
being posted here. So here it is:
Thank you for being persistent. And taking the time... many folks (and
justifiably so) would not have.
cat ./ff1c-posted-nntp_perl-beginner-170628_170608
use strict;
use warnings;
use File::Find;
my $dir = './dir1';
if (! -d $dir) {
warn "Usage tripped: line: <" . __LINE__ . ">\n",
"<$dir> not found .. aborting ..\n";
exit;
}
my %data;
my $d;
my $cnt = 0;
my $oacnt = 0;
find sub {
return unless /\A\d+\z/;
$oacnt++;
if ($data{$File::Find::dir}++ == 0 ) {
if ($cnt) {
printf "%-17s %d\n",$d, $cnt;
}
$cnt = 0;
}
$d = $File::Find::dir;
$cnt ++;
}, $dir;
printf "%-17s %d\n",$d, $cnt;
print "($oacnt) numeric files overall\n";
------- ------- ---=--- ------- -------
Output:
> ./ff1c-posted-nntp_perl-beginner-170628_170608
./dir1 3
./dir1/dir2 3
./dir1/dir2/dir3 3
(9) numeric files overall
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/