Maybe you are after something like:
use strict; use warnings; my @lines; while (<DATA>) { 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 Soc +cer Berlindis Girl Newmarket Lord, army; shield 32 Fo +otball
Prints:
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
Note that for posting questions it is much better if you provide sample code that can be run and that relying on external files makes that harder. See I know what I mean. Why don't you?.
In reply to Re: Parsing simple text, made difficult
by GrandFather
in thread Parsing simple text, made difficult
by sdyates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |