On Fri, Jun 01, 2001 at 03:29:43PM -0700, Chuck Ivy wrote:
> First post, quick question:
>
> I've got an array of hashes that I'm defining the most basic way I can...
>
> my $gSeasonID;
> my @season_list = '';
> while (@fields = $sth->fetchrow_array) {
> $gSeasonID = $fields[0];
> $season_list[$gSeasonID]{number} = $fields[1];
> $season_list[$gSeasonID]{title} = $fields[2];
> $season_list[$gSeasonID]{active} = $fields[3];
> }
First things first, you don't really nead $gSeasonID, this will work
just as well:
$season_list[$fields[0]] = $fields[1];
Second of all, I think this problem becomes a lot easier if you use
hashes of hashes, like so:
$season_list{$fields[0]}{number} = $fields[1];
Because now you can loop over the seasons like so:
foreach (keys %season_list) {
print $season_list{$_}{title}; # or do whatever to this data
}
Now you don't need to fuss with array size or index values at all.
Hope this helps!
Bill
--
Bill Stilwell
[EMAIL PROTECTED]
It's all margins.
Oh, just read my weblog: http://www.marginalia.org