Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Parsing data into an Array of Hashes

by jonadab (Parson)
on Sep 18, 2003 at 13:04 UTC ( #292376=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @stuff;
    while (<FILEHANDLE>) {
      chomp;
      push @stuff, { map {split /\s*=\s*/} split /,\s*/ }
    }
    
  2. or download this
    my @stuff;
    while (<FILEHANDLE>) {
    ...
      my %record = map {split /\s*=\s*/} split /,\s*/;
      push @stuff, \%record;
    }
    
  3. or download this
    my @stuff;
    while (<FILEHANDLE>) {
    ...
      my %record = @keysandvalues;
      push @stuff, \%record;
    }
    
  4. or download this
    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
    split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://292376]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2016-12-03 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.