Mark Wheeler wrote:
Hi,
First, thanks again for all who helped me with sorting dates with Date::Manip. That's working great.
I have another question. Below is a "sample" of a larger script. I have it working great, but I'm pretty sure the sorting and manipulation of file data is inefficient. What I'm asking is, how do I make the code more efficient? Here's the code and what it does.
[snip]
my @sorted_split_final = sort { Date_Cmp(ParseDate((split /:/, $a)[3]), ParseDate((split /:/, $b)[3])); } @sorted_split_temp;
My first reaction to this code is: Eeeuugh, such ugly code: 2 Date::Parse (I think) calls *inside* a sort {} block.
It may be syntactical, but it sure ain't pretty. Couldn't you do that date parsing when @sorted_split_temp is being populated?
I can't guarantee that that would be more efficient (read: faster). You would have to benchmark it to find out. But I think it would be a try.
jimk