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:
@listone = ([010000,010010,2],[010200,010210,5],[012359,020001,3]);
@listtwo = ([010005,010015,1],[010207,010211,4]);
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.
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:
[010000,010004,2]
[010005,010015,1]
[010200,010206,5]
[010207,010211,4]
[012359,012359,3]
[020000,020001,3]
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!
***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!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.