hi guys im running into a problem here this is my script
#!/usr/bin/perl
use CGI qw(:standard);
$header = "MIME-Version: 1.0\n";
$header .= "Content-type: text/html\n";
$header .= "\n";
#get the point parameter from nhl.html
$Team = param("points");
print "$header";
open(INFILE, "nhl_data") || die "cannot open file";
%rooms= ("points" => 0);
while(<INFILE>)
{
if($_=~/$Team/)
{
@fields=split(/:/,$_);
++$rooms{"$fields[2]"};
$rooms{"$fields[2]"} = $rooms{"$fields[2]"} +1;
print "$rooms{$_}";
}
}
what im trying to do here is: the script is getting the team name from an html file
then this name is searched on the nhl_data once it finds the team is going to count the goals on that specific team using a sum , my question is: how would i go to that specific field in this case field 3 and add each value accordingly?
nhl_data example
Sakic, Joe:Colorado Avalanche:617:994:1343
Recchi, Mark:Atlanta Thrashers:518:847:1386
Sundin, Mats:Toronto Maple Leafs:546:755:1288
Modano, Michael:Dallas Stars:523:744:1298
Roenick, Jeremy:San Jose Sharks:504:686:1300
Selanne, Teemu:Anaheim Ducks:540:597:1045
Fedorov, Sergei:Columbus Blue Jackets:469:663:1174
Brind'Amour, Rod:Carolina Hurricanes:427:685:1322
Tkachuk, Keith:St. Louis Blues:490:475:1029
Weight, Doug:Anaheim Ducks:264:700:1118
Chelios, Chris:Detroit Red Wings:183:761:1600
Lidstrom, Nicklas:Detroit Red Wings:209:714:1234
Kariya, Paul:St. Louis Blues:380:534:875
Roberts, Gary:Pittsburgh Penguins:434:469:1193
Linden, Trevor:Vancouver Canucks:372:489:1365
Kovalev, Alex:Montreal Canadiens:358:488:1047
Alfredsson, Daniel:Ottawa Senators:325:506:832
Naslund, Markus:Vancouver Canucks:366:446:1010
Nolan, Owen:Calgary Flames:379:417:1042
any suggestion would be highly appeciated
thanks guys