Hello perlfolk.
Goal: Create a hash of arrays where
hash key = match number
array[0] = home team
array[1] = away team
and then retrieve the teams by retrieving all the keys
while ( @fixture_rec = $sth->fetchrow_array ) {
my $game_id = $fixture_rec[0];
print "0=$fixture_rec[0] 1=$fixture_rec[1] 2=$fixture_rec[2]\n";
my @teams = @fixture_rec[1..2];
print "home=$teams[0] away=$teams[1]\n";
#stuff the hash
$fixture{$game_id} = [ @teams ];
}
return;
}
sub get_teamsheets {
while (($game_id, @teams) = each %fixture) {
print "Game=$game_id Home=$teams[0]\n";
}
return;
}
Here's what my print statements show when I run this
0=2827 1=mba 2=mbb
home=mba away=mbb
0=2828 1=mbc 2=mbd
home=mbc away=mbd
0=2829 1=mbe 2=mbf
home=mbe away=mbf
0=2830 1=mbg 2=mbh
home=mbg away=mbh
0=2831 1=mbi 2=mbj
home=mbi away=mbj
Game=2828 Home=ARRAY(0x83385e4)
Game=2830 Home=ARRAY(0x8338644)
Game=2829 Home=ARRAY(0x8338614)
Game=2831 Home=ARRAY(0x8338674)
Game=2827 Home=ARRAY(0x833859c)
I'm getting the match id back, but the home team is missing. I don't see
anything like this in perldsc, but if I'm over looking it, you can point me
at it. I may have gotten this idea from the Camel book, but my copy is at
work right now. Please help me to understand what I'm doing wrong.
TIA
Dave
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>