use File::Basename; use strict; my %exts; open FILE , '/some/big/file' or die "Screaming $!"; while ( ) { chomp; my $file = $_; my ($name, $path, $suffix) = fileparse( $file , '\..*' ); $exts{$suffix}++; } # Dump your hash here.