Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Parsing data into an Array of Hashes

by Wonko the sane (Deacon)
on Sep 18, 2003 at 12:57 UTC ( [id://292375]=note: print w/replies, xml ) Need Help??


in reply to Parsing data into an Array of Hashes

This is one way to do it.
#!/usr/local/bin/perl5.6.0 -w use strict; use Data::Dumper; my @records; while ( my $entry = <DATA> ) { my %rec = map { /(\S+)\s*=\s*([^\n\r]+)$/ } split( /,/, $entry ); push( @records, \%rec ); } print Dumper( \@records ); __DATA__ Field1= a value,Field2= another value, Field3= yet another value Field1= a value,Field2= another value, Field3= yet another value Field1= a value,Field2= another value, Field3= yet another value

Best Regards,
Wonko

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-18 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found