in reply to Perl printing in the wrong order

 $|++;
Let's not, shall we? It's a shame this cargo cult still creeps up it's ugly head after 15 years or so - the person making it popular should be ashamed of himself (Yes, I know who you are).

$|++; has nothing over $|=1;. Not even in the number of keystrokes. Just use $|=1;.

Not that your use here is useful. You're autoflushing the wrong handle (STDOUT), doing it after the print, closing the handle flushes output as well, and using >> causes writes to happen at the end anyway.