http://www.perlmonks.org?node_id=1014517

ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:

I have a file of about 1B records, each containing 50 tab-separated fields. I'm writing a small app to pass this file on an ad-hoc basis, selecting and concatenating various of these fields.

For example: if the input file contains

FIRST\tMIDDLE\tLAST\tSTRNO\tSTRNAME\tCITY\tSTATE\tZIP\t...\n

I might wish to extract fields 3, 1, and 6:

LAST\tFIRST\tCITY\n

My current approach begins by splitting each record into a 50-element array and then accessing each by index. It's very slow. Can someone suggest a superfast approach to doing this, given only the set of indices I wish to extract?