in reply to Re: Newbie hash/sorting question
in thread Newbie hash/sorting question
That is probably a bit inefficient, as AFAIK it copies the hash to create the anonymous hash reference. Something like this would work:
my $recordset = {}; $recordset->{name} = "Item A"; $recordset->{price} = 9.99; push @data, $recordset; # start with a new hash reference $recordset = {}; $recordset->{name} = "Item B"; $recordset->{price} = 4.99; push @data, $recordset;
Of course, declaring my $recordset; inside the loop where you fill @data is probably the nicest approach.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Newbie hash/sorting question
by msensay (Novice) on Dec 09, 2011 at 14:21 UTC | |
by aaron_baugher (Curate) on Dec 09, 2011 at 17:06 UTC | |
by msensay (Novice) on Dec 09, 2011 at 19:59 UTC |