Sekhar Reddy:

Using code tags (<c>Your code goes here</c>) would be far better than trying to manually format your code:

If you had used code tags, it would look more like the following:

use Data::Dumper; my %results = (); while ( <DATA> ) { chomp; my @row = split /,/, $_; print STDOUT "row values is:".$_."\n"; if ( (exists $results{ $row[0], $row[1] })) { if ( ( $row[2] ) < $results{ $row[0], $row[1] }->{ 'ACTDATE' } ) { $results{ $row[0],$row[1] }->{ 'ACTDATE' } = $row[2] ; } print STDOUT "inactdate--".$row[3]." \n"; print STDOUT "in memory inact--".$results{ $row[0] }->{ 'INACT +DATE' }."\n"; if ( ( defined $row[3]) && !( defined $results{ $row[0] }->{ ' +INACTDATE' } ) ) { $results{ $row[0] }->{ 'INACTDATE' } = undef ; }

Obviously not exactly like that, as I don't know how your code is normally formatted, nor did I bother to clean up the whole thing.

OK, for the errors you're encountering: I'd suggest you start looking at how you're accessing the data items you're putting in results. You're storing some items into the hash like this:

$results{ $row[0], $row[1] } = { 'A1' => $row[0], 'B1' => $row[1], 'ACTDATE' => $row[2], 'INACTDATE' => $row[3], }

but you're sometimes referring to them like:

    $results{ $row[0],$row[1] }->{ 'ACTDATE' }

but at other times you're doing things like:

    $results{ $row[0] }->{ 'INACTDATE' }

I expect the mismatched hash keys are the reason that you're getting all the "uninitialized value warnings. Clean that up and that will probably get you closer to your desired result.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^5: sorting and merging in perl by roboticus
in thread sorting and merging in perl by Sekhar Reddy

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.