@files = glob ('/export/home/date_file*); ^ ^<-- not there #### use warnings; use strict; use Data::Dumper; my %type; @type{qw(is a an at)} = (0) x 4; for my $file ( glob "*.txt" ) { open my $fh, '<', $file or die $!; while (<$fh>) { for (split) { $type{$_}++ if exists $type{$_}; } } } print Dumper \%type; my $total = 0; $total += $type{$_} for keys %type; print $total, $/;