use strict; use warnings; my @lines; while () { chomp; my @fields = split /\t/; push @lines, [@fields]; } # At this point @lines contains an array ref for each input line. # Each array ref is the list of field data for the line for (@lines) { # Do some stuff with the data print "$_->[0] is a $_->[2] $_->[1] who enjoys a good game of $_->[7]\n"; } print "\n"; # Now output the fields in a different order: for (@lines) { print "\t", join ("\t", @{$_}[0, 1, 3, 4, 7]), "\n"; } __DATA__ Berlinda Girl Newmarket Lord, army; shield 54 Soccer Berlindis Girl Newmarket Lord, army; shield 32 Football #### Berlinda is a Newmarket Girl who enjoys a good game of Soccer Berlindis is a Newmarket Girl who enjoys a good game of Football Berlinda Girl Lord, army; Soccer Berlindis Girl Lord, army; Football