- or download this
use strict;
use warnings;
#^^ for professional use to save HALF time and headache
- or download this
open (FH,$ARGV[0]) || print "could not open file" ;
# ^^open()s first ARGument as filehandle FH
...
## then it prints message
## and continues the program as if the file was opened
## and everything was ok
- or download this
my $info = <FH>;
## $info is assigned one read line from FH
- or download this
while ($info=~ /(\w+ (-?\d+ )+)/)
## LOOP while $info m//atches pattern
...
## and no substitution will be performed
}
- or download this
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
- or download this
my $word = shift (@nums);
# shifts first word
- or download this
my $sum = 0;
# $sum is 0
- or download this
my $var = ($info);
# i think $var is supposed to contain the numbers from $info
- or download this
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.
- or download this
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..