in reply to perl sort on windows
This piece of code fails (note: it isn't Perl that's failing, it's your environment) because you are calling out to external tools and expecting them to behave similarly across multiple platforms. This is almost always going to bite you in the ass and cause problems.
If you want it to be portable and run correctly on Windows, get rid of the external sort command, and do the work in Perl. Read in your file, write a little Perl sort routine, and you'll have something that will work everywhere you run it.