in reply to Re: Cache, sort, and filter XML response
in thread Cache, sort, and filter XML response
my %sort_xml = @output;
You are coercing an array to a hash here. That hash is a structure in which every odd element of the original array is a key, and every even element a value. So if you have an odd number of elements in an array, perl warns you that there's no value for the last key.
I guess this is not what you want.
<update>
Having a second look, your array contains alternatingly just the results of $xml->cdr() and $xml->Link(). At some point in the loop processing, one of these calls seems to return just an empty list, which is why you get an odd element count.
</update>
foreach my $key ( sort { $sort_xml{$a} <=> $sort_xml{$b} } ( keys(%sor +t_xml) ) )
Apart from the fact that the thingies you are trying to sort live in a package that makes use of overload, you are trying to sort them numerically. Again not what you want...
I have no idea of what each element in @out looks like (is each of them a hash? an inside-out object?), so I can only give some general advice on how to sort them:
@sorted = sort { $a->attr_method cmp $b->attr_method } @out;
where attr_method is the method to look up the attribute after which you want to sort those elements.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|