in reply to Total Files

Assuming that you know how to opendir and readdir you just have to test whether it's a file or not with the -f operator. eg:
opendir (D,".")|| die "nope sorry"; for (readdir(D)){ ++$count if -f; } print $count;

Replies are listed 'Best First'.
Re: Re: Total Files
by particle (Vicar) on Jun 08, 2001 at 16:12 UTC
    here's a different twist. at first i thought map was a good fit for this.... merlyn has helped me learn to love map.
    opendir D,'.' or die "opendir: $!\n"; print((map{$i+=!-f}readdir(D))-$i);
    of course, for a newbie, this isn't appropriate as is, since without temp variables it's a little hard to understand.
    i just thought i'd post it because i prefer opendir and readdir, and i love map.

    =Particle