Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    #^^ for professional use to save HALF time and headache
    
  2. 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
    
  3. or download this
    my $info = <FH>;
    ## $info is assigned one read line from FH
    
  4. or download this
    while ($info=~ /(\w+ (-?\d+ )+)/)
    ## LOOP while  $info  m//atches pattern
    ...
    ## and no substitution will be performed
    
    }
    
  5. 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
    
  6. or download this
    my $word = shift (@nums);
    # shifts first word
    
  7. or download this
    my $sum = 0;
    # $sum is 0
    
  8. or download this
    my $var = ($info);
    # i think $var is supposed to contain the numbers from $info
    
  9. 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.
    
  10. 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..