alanonymous has asked for the wisdom of the Perl Monks concerning the following question:
Hello, Perl Monks,
I think I have a fairly easy problem, but I'm having problems approaching it. I've completed the portion of code to read in files and parse out the exact data I need, but now I'm having a problem figuring out to convolute my dates.
Essentially I have two arrays, each of which holds a list of another array that has three values. Here is a super simple example of what I am trying to describe:
I need to combine these arrays into a single list, organized by time that does two special things: ***in overlapping dates/times the lower value is chosen which forces some of the items to be split, and also needs to break the value into two for a change in days.***
The solution to the above example would be an array consisting of the following arrays:
***EDIT***
What I'm looking at now is:
I'm not looking for a solution per say, but I really need some help with how to approach the problem. I wouldn't say no to a solution though :) Like I said, I've done the ~30 lines of code to get the data to the point where the fun begins, but that's where I'm having problems
Thoughts, anyone?
Thanks!
I think I have a fairly easy problem, but I'm having problems approaching it. I've completed the portion of code to read in files and parse out the exact data I need, but now I'm having a problem figuring out to convolute my dates.
Essentially I have two arrays, each of which holds a list of another array that has three values. Here is a super simple example of what I am trying to describe:
The format for the inside array is DDTTTT,DDTTTT,V where DD is a two digit date, TTTT is a 24 hour time value, and V is some decimal value.@listone = ([010000,010010,2],[010200,010210,5],[012359,020001,3]); @listtwo = ([010005,010015,1],[010207,010211,4]);
I need to combine these arrays into a single list, organized by time that does two special things: ***in overlapping dates/times the lower value is chosen which forces some of the items to be split, and also needs to break the value into two for a change in days.***
The solution to the above example would be an array consisting of the following arrays:
The solution to the above is easy and straight-forward to do by hand, but this will have to be done for hundreds+ daily, and perl is perfect for it![010000,010004,2] [010005,010015,1] [010200,010206,5] [010207,010211,4] [012359,012359,3] [020000,020001,3]
***EDIT***
What I'm looking at now is:
**********@combined = sort {$a->[0] <=> $b->[0]} (@listone,@listtwo); foreach (@combined) { #check for overlapping times and make sure the smallest V time is + listed during the overlap piece #XXXXXXX #break the timespans apart if it covers the crossing of a new day #XXXXXXX }
I'm not looking for a solution per say, but I really need some help with how to approach the problem. I wouldn't say no to a solution though :) Like I said, I've done the ~30 lines of code to get the data to the point where the fun begins, but that's where I'm having problems
Thoughts, anyone?
Thanks!
Back to
Seekers of Perl Wisdom