Hi all,
I'm sure I'm just being stupid here but I can't see where:
I have an array of hash references that I'm trying to sort by one of the
key/value pairs in the hashes (see code below).
I get various errors, the current one being:
Can't coerce array into hash at
/web/secure.miswebdesign.com.on-water/cgi-bin/manager.pl line 2392.
Line 2392 is the line where the sortfunc function is defined.
Thanks in advance for much needed help :)
Cheers,
Nigel
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
my @boat_list;
foreach my $boat ( $boats->findnodes("//boat") ) {
my $section;
foreach my $ab ( $boat->findnodes("section") ) {
($section = $ab) if ($ab->getAttribute("title") eq "General Details");
}
my $boat_details = {};
$boat_details->{num} = $boat->getAttribute("num");
$boat_details->{name} = $section->findnodes("name")->[0]->firstChild->data;
$boat_details->{type} = $boat_type->getAttribute("title");
$boat_details->{price} =
$section->findnodes("price")->[0]->firstChild->data;
push @boat_list, $boat_details;
}
sub sortfunc { $a->{name} cmp $b->{name}; }
my @sorted_boats = sort sortfunc @boat_list;
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>