The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to declare hashes in KSH similar to Perl ? tipsy Shell Programming and Scripting 2 08-03-2006 03:24 PM
PERL question jerardfjay Shell Programming and Scripting 13 10-25-2005 05:53 PM
How To Sort Array of Hashes ?? coolguyshail Shell Programming and Scripting 3 05-09-2005 10:31 AM
perl: hashes, whiles, and last effigy Shell Programming and Scripting 0 02-11-2005 12:23 AM
CGI passing arrays/hashes to another CGI script WIntellect Shell Programming and Scripting 2 01-13-2003 11:22 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-09-2008
lucho_1 lucho_1 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 7
perl hashes question

hi guys im running into a problem here this is my script

Code:
#!/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

Code:
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

Last edited by Yogesh Sawant; 04-09-2008 at 01:04 AM.. Reason: added code tags
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0