in reply to Re: file ext counter.
in thread file ext counter.
your
seems a little clumsy. considerif (($fname =~ /\./) && !($fname =~ /\.$/)) { $fname = lc($fname); @temp= split(/\./, $fname); $hash{$temp[-1]}++; } else { $hash{"no ext"}++; }
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"if ($#temp >0) {$hash{@temp[-1]}++} else {$hash{""}++}
|
|---|