in reply to Hash ref and file extensions
This code should do what you need:
open(F, '<', './files.txt') or die "open: $!"; while ($filename = <F>) { chomp($filename); $dot = rindex($filename, '.'); if ($dot > -1) { $extension = substr($filename, $dot+1); $extensions{$extension}++; } else { $extensions{'_without_extension'}++; } } close(F); while (($key, $value) = each %extensions) { print "$key -> $value\n"; }
Ciao, Valerio
update: thanks liz!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash ref and file extensions
by liz (Monsignor) on Aug 16, 2003 at 12:50 UTC |