Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Perl script to read a tab delimited text file

by maa (Pilgrim)
on Apr 01, 2004 at 11:54 UTC ( [id://341595]=note: print w/replies, xml ) Need Help??


in reply to Perl script to read a tab delimited text file

I don't see what your problem is... if the records are "fixed width" (i.e. there are 8 fields per line) then just check for define'dness of $line4 which should be the id of the 2nd part of the record... then save that record however you were going to savr the previous one.

You should note, however, that your code is only every going to save the last record you read as you have hard-coded the array/indices in your while loop. :-)

Why don't you consider using a hash where the key is the numeric ID and the content is an anon array?

while(<DAT>){ @line = split(/\t/,$_); $myhash{$line[0]} = [$line[1],$line[2],$line[3]]; }

And have you actually tried your split on tab separated nothingness?

HTH - Mark

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 00:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found