in reply to A Beginner Needs Homework help

Ok - here is a line-by-line commentary on your code. Look up the relevant documentation to fix.
open (FH,$ARGV[0]) or print "could not open file" ; # Better to use the 3-argument version of "open", and lexical file han +dles : # open ( my $fh, "<", $ARGV[0]) or print "could not open file '$ARGV +[0]'; $!"; my $info = <FH>; # This reads ONLY the first line of the file.. # You need to put the file reading into a "while" loop that exits at E +OF # Typically, this is written : while (<$fh>){ ..do stuff .. } while ($info=~ /(\w+ (-?\d+ )+)/) # move regex stuff inside the whi +le { my $info =~ s/(\w+ (-?\d+ )+)//; # Careful with spaces inside +regexs } my @nums = split(/:/,$info); # These need to be inside the while my $word = shift (@nums); my $sum = 0; my $var = ($info); foreach $var (@nums) # Adding up stuff needs to be inside the while { $sum = $sum + $var; } my %hash = ($word = $sum); # You mean ($word => $sum) print @nums; # try print "@nums\n"; That will space out the numbers, a +nd add a newline.

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992