http://www.perlmonks.org?node_id=673660


in reply to reading a delimited file and selecting values from it

It's possible there's some tools out there that would make this easier, but to tackle it yourself, here are some ideas to get you started. If you need specific help on a certain part of this, just ask.

Create a hash or something to hold the data you want to keep. One idea might be to have the keys be like '1', '1.5', '2', '2.5' etc. (i.e. a key for the hour and a key for the half hour for each of the 24 hours).

Open the file and go through it line by line, using a regex to separate each line into separate chunks for Quote, Hour, Minute, and Second. This should be relatively painless because the lines seem to be delimited pretty clearly.

Look at the Hours and Minutes returned from the current match to find out where that line should be placed in your hash. (i.e. if $hour = 12 and $minute = 37, it would go in $hash{'12.5'}) and place the quote there. Assuming the file is in chronological order, this should do it for ya. If it's not, you may have to keep track of the seconds and do a comparison to determine if the new value is "higher".

Hopefully that gets you going in the right direction.


I'm a peripheral visionary... I can see into the future, but just way off to the side.