So I was going to start off by sorting the hash based on different parameters passed, and move onto the caching and filtering when I get this part done. I try and sort like this
while LOOP { push @output, $xml->cdr( $xml->$label1( $hold_col_val . " " . $hold_col_val +2 ), $xml->$label2($total_cdr_count), $xml->$label3($total_call_count), $xml->$label4($total_error_count), $xml->$label5($formatMin), $xml->$label6($formatASR), $xml->$label7($formatPDD), $xml->$label8($formatDUR), $xml->$label9($hold_min_date), $xml->$label10($hold_max_date), $xml->$label11($link)); } my %sort_xml = @output; foreach my $key ( sort { $sort_xml{$a} <=> $sort_xml{$b} } ( keys(%sor +t_xml) ) ) { print $key $sort_xml{$key}; }
But I get this error:
Odd number of elements in hash assignment at rpt.pl line 960. Operation "<=>": no method found, left argument in overloaded package XML::Generator::pretty, right argument in overloaded package XML::Generator::pretty at rpt +.pl line 961.
I am guessing I need to somehow adjust it to tell it which label 1-11 to sort on? What's that syntax? I want the order of the XML elements to be the same, but to print to screen in an ASC or DESC order based on the value of the element

In reply to Re: Cache, sort, and filter XML response by hallikpapa
in thread Cache, sort, and filter XML response by hallikpapa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.