in reply to Re^4: sorting and merging in perl
in thread sorting and merging in perl
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.
|
|---|