Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Convert Week Of Year to Dateby Limbic~Region (Chancellor) |
on Feb 01, 2005 at 19:17 UTC ( [id://427016]=note: print w/replies, xml ) | Need Help?? |
ear,
Beyond the sagely advice already provided, I wanted to mention a few things for further consideration. First, your hash keys make it difficult to sort on them chronologically which presumably you would want to do: If you can, it would be better to use a ISO date string that can be sorted and will only require conversion one time and not every time you need to print results: If you can't do that, then perhaps you could change your data structure to something like $data{year}{week}{issue} = $count; then it will be much easier sorting. The second thing is that it is generally a waste to sort a list to find the top or bottom of the list. There are routines known as water-mark algorithms that do this much more efficiently. Instead of sorting the entire list and then throwing away most of the work, I would suggest using something similar to: Note that the commented splice will effectively do the same thing as the array slice. Depending on the size of the array, it may or may not be more efficient. Cheers - L~R
In Section
Seekers of Perl Wisdom
|
|