Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

How do I retrieve specific column values from a table of records?

by Anonymous Monk
on Jun 08, 2000 at 01:05 UTC ( [id://16960]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://16960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found