I'm trying to parse a logfile that has timestamped entries in it. The format is like this:
01/14/2014 23:44:12 <data1> <data2>
01/14/2014 23:44:12 <data1> <data2>
01/14/2014 23:44:13 <data1> <data2>
I'm splitting the line and using data2 as the key for a hash, and then pushing date, time, and data1 into an array that is the value, like this:
push (@{$myHash{$data2}{info}}, "$date,$time,$data1");However, my input file is not guaranteed to be sorted by time (in particular, some entries tend to be out of order by a second or two), and I need the output to be sorted. How can I sort those, either when I push entries into the array, or as I'm parsing it? I'm aware of Time::Piece, which I assume will help here, but I'm having trouble wrapping my head around the big picture of how to sort, especially in an efficient manner, as some of the input files are going to be pretty large.
In reply to sorting logfiles by timestamp by jasonl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |