Your match doesn't match when readdir returns ., so $1's value isn't changed by the match, and it was previously undefined.
use strict; use warnings; my %ext; opendir my $dh, './' or die $!; for (grep { -f } readdir $dh) { ++$ext{$1} if /\.([^.]+)$/; } print "$_ - $ext{$_}\n" for keys %ext;
Alternate:
use strict; use warnings; my %ext; opendir my $dh, './' or die $!; ++$ext{$1} for map { -f && /\.([^.]+)$/ ? $1 : () } readdir $dh; print "$_ - $ext{$_}\n" for keys %ext;
In reply to Re: File ext number
by ikegami
in thread File ext number
by Kirche
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |