Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I took at a stab at coding this thing. I don't know if this helps or not, you may find the function anyCompare useful...Could be some problems with this code...Dunno..its early in the morning here...
my $test_array_ref = [ [ 'Amber Benedit C', '23455443', '2008-01-11', 'X',.... ....... like in your post........ ]; my %accountNames =(); foreach my $record_ref (@$test_array_ref) { my ($name, @new_data) = @$record_ref; if (exists $accountNames{$name}) { my @current_data = @{$accountNames{$name}}; my $i =0; foreach my $new_thing (@new_data) { if (anyCompare($new_thing,$current_data[$i])>0) {$current_data[$i]= $new_thing}; $i++; } @{$accountNames{$name}}=@current_data; } else { $accountNames{$name} = [@new_data]; } } foreach my $name (sort keys %accountNames) { print "NAME=$name\n"; print join ("\n", map{/^\s*$/ ? '""' : $_} @{$accountNames{$name}}),"\n"; print "\n"; } sub anyCompare #returns <0,0,>0 like normal <=> or cmp { my ($a,$b) = @_; if ( isNumeric($a) && isNumeric($b) ) {return $a <=> $b} return ($a cmp $b) } sub isNumeric #returns True/False { my $string = shift; my $isNumeric = ($string =~ m/^[-+]*\d+(\.\d+)?$/); return $isNumeric; } __END__ prints: NAME=Amber Benedit C 23455443 2008-01-11 X 11 0 7.00 "" 2 2 3 "" -2.0 "" "" "" "" "" "" 3.0 2008 1112399 NAME=Amy Israel D 22345666 2008-03-04 X 999 0 8.00 "" 0 2 0 "" -5.00 "" "" "" "" "" "" 2.0 2008 1112399 NAME=Auser Ferro 987778999 2008-11-30 W 888 0 0 "" 1 2 4 "" -5.00 "" "" "" "" "" "" 2.0 2008 1112399 NAME=Yuong John 22357790 2008-03-27 W 50 0 4.00 "" 4 2 3 "" 0 "" "" "" "" "" "" 3.0 2008 1112399 NAME=Zilda Mil 88997665 2008-05-12 X 999 0 4.00 "" 1 2 3 "" 0 "" "" "" "" "" "" 14.0 2008 1112399

In reply to Re: Loosing Negative Values in Array Ref by Marshall
in thread Loosing Negative Values in Array Ref by Anonymous Monk

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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (5)
    As of 2015-07-07 04:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (87 votes), past polls