in reply to Simple Totals Example (Help Needed)

two things:
  1. you should increase $tot, instead of assigning it the current value of $hash{$siteID}
  2. you should print $tot outside the while; also, try adding a newline; that would visualise what happens now
In code:
while (<F>) { ($siteID, $siteAge, $siteDistance) = (split/,/)[0,1]; $hash{$siteID} += $siteAge; $tot += $siteAge; } print $tot, "\n";
Hope that helps :)

Replies are listed 'Best First'.
Re^2: Simple Totals Example (Help Needed)
by doctormaze (Initiate) on Apr 02, 2006 at 23:06 UTC
    Thanks, much appreciated!!! };-> p.s. Incredibly quick reply!