As I recommended in Re (tilly) 1: Sorting a large file, I would tryFile::Sort before the above code.No problem, except this was a demonstration of merge sorting, nothing more, and identified as a quick hack. Merge sorting is not rocket science and a valid solution to the problem at hand.
Secondly for temporary files, use File::Temp instead of hand-rolling.For eons, tempfiles have been created with tmpnam() from POSIX. Nothing wrong with that. In fact, I suggested exactly that. Yes, File::Temp might be your solution, but not everyone's. TIMTOWDI
And thirdly the fact that you defined your store function inside of your sortsub function suggests some confusion on your part. You cannot get nested functions that way.No, no confusion. Did you read the code? You'll note that's NOT a nested subroutine declaration. The sort subroutine is all on one line. The bare block is to provide a lexical scope. Read it again.
As a matter of personal taste I would drop the prototype, use strict, etc, etc, etc. But the three I gave above are the biggies.For something written in 20 minutes, that works, demonstrates the topic at hand, has (or suggests) idiomatic perl coding... I didn't think it was too bad.
PS: The prototype is NECESSARY. Comment was there for your benefit. Read it and you'll discover why.
In reply to Re: Re (tilly) 3: Sorting a large file
by clintp
in thread Sorting a large file
by c-era
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |