To make sure I loaded the hash correctly, I used the following code to dump the contents of the hash to a page:Abv Team ------------------ WSH Washington BUF Buffalo ANA Anaheim CMB Columbus NJ New Jersey ATL Atlanta MTL Montreal
Where %teams is obviously the list of teams, where the abbreviation is the key and the name of the team is the value. The above code did what it was intended - it printed a list of all 30 teams in the league.for my $key (keys %teams) { print $key . " - " . $teams{$key} . "<BR>\n"; }
The next step was to read through a comma-delimited file (using DBI and DBD::CSV) with the desired stats (what's above and below this works fine):
@table is an array I hand off to HTML::Template to build a result table. The table prints as intended, however, all of the team names are blank. But if I change this:while (my $row = $sql->fetchrow_hashref) { my %row_data; $team = $row->{'Teams'}; $row_data{TEAM} = $teams{$team}; $row_data{GP} = $row->{'GP'}; $row_data{W} = $row->{'W'}; $row_data{L} = $row->{'L'}; $row_data{T} = $row->{'T'}; $row_data{OTL} = $row->{'OTL'}; $row_data{P} = $row->{'P'}; push(@table, \%row_data); }
to this:$row_data{TEAM} = $teams{$team};
I get the abbreviation for the team I intended. Even stranger, if I change the line to this:$row_data{TEAM} = $team;
I get NY Rangers to show up for all 30 teams. Why are my hash values coming back blank?$row_data{TEAM} = $teams{"NYR"};
I tried doing a super-search for the above problem and didn't seem to turn up anything. Can anybody shed some light on this? It's really frustrating me. I had to put down perl for too long a time (how dare work interfere with something fun ;) and thought I'd get back into the swing of things with something easy.
Thanks in advance,
MrCromeDome
In reply to Need help hashing this out. . . by MrCromeDome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |