Here is a more verbose solution and assumes that your files are being stored in an array. In the following code, the array is named @files. I have only tested this on files which all have extensions.
my %extensions; for my $file (sort @files) { my @split = split(/\./,$file); my $key = $split[1]; my $num = 1; if (exists $extensions{$key}) { $extensions{$key} += $num; } else { $extensions{$key} = $num; } } while (my ($key,$value) = each %extensions) { print $key." - ".$value."\n"; }
In reply to Re: File ext number
by Lady_Aleena
in thread File ext number
by Kirche
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |