in reply to Learning Perl, Hashes Help

Instead of doing this…

open(FILE, '/location/data/p4.txt') or die "Cant't open file: $!\n +";

…do this…

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;

And instead of doing this…

my %myhash = (); my @data = (); chomp(@data = <FILE>); foreach (@data) { %myhash = (@data => $k++); }

…do this…

my %total_values_by; while (my $value = <$fh>) { chomp $value; $total_values_by{$value}++; }