my $root = rel2abs (shift || '.');

I wouldn't use rel2abs: if I give '.' as an argument, I expect it to be honored. Unless there were some specific option to explicitly instruct the program to do otherwise, that is.

my @extList = @ARGV; @extList = ('pl', 'pm') if ! exists $extList[0];

How 'bout

my @extList = @ARGV ? @ARGV : qw/pl pm/;

instead?

my $lines = 0; my $files = 0;

No need for the initializations. Maybe you want them anyway for (your) clarity. For me,

my ($lines, $files); # is clear enough
sub count { my $name = $File::Find::name; return if -d $name;

Maybe in this case you would prefer to use the no_chdir => 1 option to find() which seems more appropriate...

my ($ext) = $name =~ /\.([^.]*)$/; return if ! defined $ext or ! exists $exts{$ext};

How 'bout

return if grep $name =~ /\.\Q$_$/, @extList;

?

return if ! open inFile, '<', $name;
open my $in, '<', $name or # and I don't need close() (warn "Ouch: $name => $!\n"), return;
++$lines while (<inFile>);

Hmmm, I always recommend against slurping in whole files (if unnecessary), but perhaps

$lines+=<$in>;

...


In reply to Re: Count file lines in a directory tree by blazar
in thread Count file lines in a directory tree by GrandFather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.