----- Original Message -----
Sent: Monday, January 19, 2004 9:30
AM
Subject: arrays of hashes
Hi,
I'm currently
doing something along the lines of this
to create arrays
of hashes ;
my
%data;
sub
filldata
{
my $type;
foreach $type ('Reference','Object')
{
foreach
(1..10)
{
my %info;
GetData( \%info );
push ( @{$data{$type}}, \%info );
}
}
sub
GetData
{
my $h_info = shift;
# populate hash ref with
data
$h_info->{FILE} = "erm .. file info";
$h_info->{VERSION} = "erm ... version info";
}
The problem is
putting my %info in the foreach construct is the only way
to get a 'new'
hash. Before that i tried ;
undef
%info;
%info =
();
%info =
{};
But none of these
would create a *new* hash. The upshot of this is that
the GetData
populates the same single hash.
Basically is this
okay, because to me it looks a bit ugly and clunky.
Chairs
Nick