Are you saying that the dot (.) directory somehow makes it past the grep {-f} filter in the OP's code?

I guess I was without realizing it. Obviously, that's not true and my explanation is wrong. Take two:

$ext{$1} += (m/([^.]+)$/);
means something close to
$ext{$1} = $ext{$1} + (m/([^.]+)$/);

Well, actually more like the following, but it doesn't matter for this discussion:

alias $temp = $ext{$1}; $temp = $temp + (m/([^.]+)$/);

Either way, you are relying on Perl evaluating the RHS of the "+=" operator before its LHS, and that's not how Perl operates. In fact, Perl doesn't document how it operates in this circumstance, and that's the reason it's generally a no-no to change and use the same variable in the same expression.

Even though my earlier explanation was wrong, the solutions I posted still avoid the problem.

Update: Improved phrasing by inlining footnotes.


In reply to Re^3: File ext number by ikegami
in thread File ext number by Kirche

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.