open(FILE, '/location/data/p4.txt') or die "Cant't open file: $!\n"; #### use strict; use warnings; use autodie qw( open close ); # ... my $file = shift; # The input file name is a command-line argument open my $fh, '<:encoding(ASCII)', $file; # Or whatever the correct character encoding is # ... close $fh; #### my %myhash = (); my @data = (); chomp(@data = ); foreach (@data) { %myhash = (@data => $k++); } #### my %total_values_by; while (my $value = <$fh>) { chomp $value; $total_values_by{$value}++; }