in reply to Use temporary file or cache
I then loop through the xml file again to find and print out all the actual blog posts. On each pass I search the entire temporary file for any comments that start with the post url and add those comments to the post
...
Is there a more efficient way of doing this?
Yes. Store the the comments with the post URL as the key in an hash of arrays, ie
my %comments = ( 'http://url.to/post' => [ $comment1, $comment2, .. ], ... )
And on the second pass simply look it up.
If the data is too large and doesn't fit all into memory, use something like DBM::Deep to store it in a file, but preserve fast lookup.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Use temporary file or cache
by andrewheiss (Initiate) on May 28, 2009 at 09:20 UTC | |
by moritz (Cardinal) on May 28, 2009 at 09:25 UTC | |
by ig (Vicar) on May 28, 2009 at 12:51 UTC |