Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Parsing data into an Array of Hashes

by Wonko the sane (Deacon)
on Sep 18, 2003 at 12:57 UTC ( #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


Comment on Re: Parsing data into an Array of Hashes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (19)
As of 2014-11-24 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (142 votes), past polls