in reply to Sorting array of hashes according to key value

Since the SORT issue is resolved by previous commentators - here is my $0.02 towards perl style and object design:

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:

for my $hashref (@{$self->{Items}}) { my $d = Dumper($hashref); print "$d\n"; # my $date = $hashref->{Date}; }
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:
my $file = shift(); if ($file){ $self->set_items($file); }else{ $self->{Items} = (); }
This allows you the option of calling the "new" function like this:
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
    Thanks a lot for all the indications.
    You got I'm trying to learn objects as well... :) R.