use strict; use warnings; #^^ for personal use to see where I've messed up open (FH,$ARGV[0]) || print "could not open file" ; my $info = ; # ^^This opens whatever file is associates with the program # i.e - perl thisassignment documenthechooses # that file is placed into $info after it's read while ($info=~ /(\w+ (-?\d+ )+)/) { my $info =~ s/(\w+ (-?\d+ )+)//; } # Identifies the pattern in file. Identifies one or more words (\w+), one or more #numbers(\d+),, also searches for new lines (-?) . my professor gave us this #pattern code so I might be totally wrong. I'm not very good with pattern yet.. my @nums = split(/:/,$info); #takes out colon where ever it may be in the $info scalar, @nums is a array with #those values my $word = shift (@nums); # shifts first word my $sum = 0; # $sum is a empty scalar my $var = ($info); # i think $var is supposed to contain the numbers from $info foreach $var (@nums) { $sum = $sum + $var; } #this is to add the numbers together. Sum is empty, so with every new number #that occurs it goes into sum and adds to whatever number is in var. i hope I'm #explaining that right. my %hash = ($word => $sum); #the new sum goes into the hash as a key and the color is in the list, thats how #they associate with each other.. print @nums;