in reply to Perl LineCount

It won't run on Unix because the directory delimiter is not a blackslash. This is why you should use File::Find instead of a hand-rolled directory recursion.

Here's some similar code I just whipped up, doing roughly the same thing:

use File::Find; my @topdirs = @ARGV; @ARGV = (); find sub { push @ARGV, $File::Find::name if /\.p[lm]\z/ and -f; }, @topdirs; my $count = 0; @ARGV or die "No files to process!\n"; $count++ while <>; print "Total $count lines\n";

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Perl LineCount
by zoonek (Novice) on Jul 19, 2002 at 11:19 UTC
    Under Linux, it could be as short as:
      wc -l **/*.pm
    The syntax is that of zsh. It is much more tiring to type, but one can be more portable with:
    wc -l `find -name "*.pm"`
    It doesn't even need Perl.