ah, I see why you'd want to use
$hash{@temp[-1]}++
but this exhibits bad behavior for files with no extention at all!
update
your
if (($fname =~ /\./) && !($fname =~ /\.$/)) {
$fname = lc($fname);
@temp= split(/\./, $fname);
$hash{$temp[-1]}++;
}
else {
$hash{"no ext"}++;
}
seems a little clumsy.
consider
if ($#temp >0)
{$hash{@temp[-1]}++}
else
{$hash{""}++}
which sees if there's more than 1 bucket in @temp. If there is, we know the lastmost one's the extention. If there isn't we know the filename has no extention.
in fact, I think this can be shortened to
<code>
if ($#temp)
<code>
but that's not a big deal. I kept the hash named "" for the highly special case of a file, e.g. "foo.no ext"
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.