in reply to Re^2: sorting and merging in perl
in thread sorting and merging in perl
First you should show what you tried and how it failed (How do I post a question effectively?).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: sorting and merging in perl
by Sekhar Reddy (Acolyte) on Jul 29, 2018 at 14:37 UTC | |
-------I am getting error as uninitialized variable----------
2018-08-02 Athanasius added code tags | [reply] [d/l] [select] |
by roboticus (Chancellor) on Jul 29, 2018 at 20:19 UTC | |
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:
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:
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. | [reply] [d/l] [select] |
by Cristoforo (Curate) on Jul 30, 2018 at 16:32 UTC | |
The code you posted is (with some minor changes). Split the line into 4 named variables instead of @row (makes the problem clearer). Eliminate quoting keys to the hash when they exist of all word characters (so don't need to be quoted). The output gives erroneous results because you include non-contiguous records. The output with is:
To get the results you want doesn't require a hash. This gives the desired results: The input file is:
| [reply] [d/l] [select] |
by Sekhar Reddy (Acolyte) on Aug 08, 2018 at 14:48 UTC | |
Hi Athanasius, First of all thank you very much for your try. I tried with your code, but still that is also giving some incorrect results. Below fyi. Input data that i have considered below
The output which i have got is below
Here 1st line and 4th line in output are incorrect: Ex:
Here expected result in output 4th line is 7900724611,200906889,20180601,20180728 | [reply] [d/l] [select] |
| |