in reply to Re: sorting and merging in perl
in thread sorting and merging in perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: sorting and merging in perl
by marto (Cardinal) on Jul 28, 2018 at 18:25 UTC | |
First you should show what you tried and how it failed (How do I post a question effectively?). | [reply] |
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 | |
| |
|
Re^3: sorting and merging in perl
by poj (Abbot) on Jul 30, 2018 at 14:17 UTC | |
Is this a new requirement or just an addition scenario to the original post sorting and merging in perl ? poj | [reply] |
by Sekhar Reddy (Acolyte) on Jul 30, 2018 at 15:45 UTC | |
Its an additional scenario to the main requirement, I thought this additional scenario may not be done and hence i am looking for new has to store this result</p | [reply] |
by poj (Abbot) on Jul 30, 2018 at 16:07 UTC | |
I'm struggling to understand the logic here. In the original post you have records 7900724677,200906871,20180101,20180228 7900724677,200906872,20180301,20180330 7900724677,200906873,20180401,20180420 creating the record 7900724677,200906871:200906873,20180101,20180420 but also you now want these records 7900724655,200906888,20180416,20180522 7900724655,200906889,20180601,20180720 7900724655,200906889,20180724,20180728 7900724655,200906888,20180730,20180830 7900724655,200906890,20180905,20180930 7900724655,200906890,20181005,20181030 7900724655,200906890,20181104, to create 2 records 7900724655,200906889,20180601,20180728 7900724655,200906890,20180905, Is that correct ? poj | [reply] |
by Sekhar Reddy (Acolyte) on Aug 08, 2018 at 14:27 UTC | |
by poj (Abbot) on Aug 08, 2018 at 18:44 UTC | |