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?.


DWIM is Perl's answer to Gödel

In reply to Re: Parsing simple text, made difficult by GrandFather
in thread Parsing simple text, made difficult by sdyates

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.