in reply to Sorting array of hashes according to key value
First ++ ysth on making the "perlish" loop. Here is a way to get rid of the extra array copy/intermediate/unnecessary variable " @items" for the same code segment:
AN additional option is that your "new" method could allow for early loading of the structure if it replaced "$self->{Items} = ();" with the following lines:for my $hashref (@{$self->{Items}}) { my $d = Dumper($hashref); print "$d\n"; # my $date = $hashref->{Date}; }
This allows you the option of calling the "new" function like this:my $file = shift(); if ($file){ $self->set_items($file); }else{ $self->{Items} = (); }
my $list = new List($file);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting array of hashes according to key value
by rbi (Monk) on Nov 28, 2003 at 20:48 UTC |