use strict;
use warnings;
#^^ for professional use to save HALF time and headache
####
open (FH,$ARGV[0]) || print "could not open file" ;
# ^^open()s first ARGument as filehandle FH
##################^^^ except when it can't open file,
## then it prints message
## and continues the program as if the file was opened
## and everything was ok
####
my $info = ;
## $info is assigned one read line from FH
####
while ($info=~ /(\w+ (-?\d+ )+)/)
## LOOP while $info m//atches pattern
## pattern is ...
{
my $info =~ s/(\w+ (-?\d+ )+)//;
## does nothing in effect
## technically, creates new variable $info
## attempts to remove using s///ubstitution operator
## pattern from $info
## attempts to replace pattern with nothing
## $info is empty new variable
## so the pattern will not match
## and no substitution will be performed
}
####
my @nums = split(/:/,$info);
## a COPY of $info is split at the colons,
## the $info string is CUT apart at the colons
## the colons are not kept they're thrown away,
## the remaining strings are stuffed into @nums
####
my $word = shift (@nums);
# shifts first word
####
my $sum = 0;
# $sum is 0
####
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 i
+n 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..