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

The file is in the form of records and columns. I want to retrieve values only for a specific coloumn.How do I do that? EX:
name address phone city chang 12, annie road 201-243-6751 newark ming 13,dgadadgagd 62839871273 trenton gigi 14,gasdha 982318791 wilmingto
I want to retrive values for phone and address columns only.

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I retrieve specific column values from a table of records?
by le (Friar) on Jun 08, 2000 at 01:30 UTC
    It'd be easy if your file had a unique data seperator, like ";" or maybe "|". Then you could split() the rows on that seperator.
    open (FILE, "data.txt") or die $!; while(<FILE>) { @array = split(/;/); print $array[1], $array[2]; } close(FILE);
    Looks like the original data was tab-separated. split("\t") would work there. -- Ed.
Re: How do I retrieve specific column values from a table of records?
by BBQ (Curate) on Jun 08, 2000 at 03:16 UTC