in reply to reading from middle of file

Beware!
split(/\s=\s/) will not do what you think it should.

Try this one:

#!/usr/bin/perl use strict; use warnings; my %hash; open(ANSWERTALLY, "answertally.dat"); while(<ANSWERTALLY>) { next unless /^Running totals:/ .. /^Averages:/; # by davorg next if /^$/; # next line if empty next if /^Running totals:/; # by davorg last if /^Averages:/; # by davorg my ($key, $value) = split(/:/); # you actually just want to split by + ':' $value =~ s/\s*//g; # remove whitespace globally $hash{$key} = $value unless $value eq ""; # add to hash only if valu +e is holding data } close(ANSWERTALLY); for my $key(sort keys %hash) { print "\$key: $key\t\$hash{\$key}: $hash{$key}\n"; } __END__ __OUTPUT__ $key: Question 1 $hash{$key}: 60 $key: Question 2 $hash{$key}: 123 $key: Question 3 $hash{$key}: 99