Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Parsing CSV into a hash

by GrandFather (Saint)
on Sep 19, 2005 at 22:30 UTC ( [id://493318]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parsing CSV into a hash
in thread Parsing CSV into a hash

That's right. Note also that if there are too few fields in a line this simply assigns undef rather than generating an invalid access as your original code did.

If you are sure that the first line contains the header line then you can simply:

$_ = <DATA> or die "Empty file"; chomp; # Throw away the first two fields (#, username) in the header (undef, undef, @fields) = (split /\t/);

before the loop.


Perl is Huffman encoded by design.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://493318]
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-03-28 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found