Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Array of Hashes population

by Roy Johnson (Monsignor)
on Mar 06, 2008 at 17:10 UTC ( [id://672510]=note: print w/replies, xml ) Need Help??


in reply to Array of Hashes population

A slice assignment would spare you walking through the columns and maintaining a counter.
#!perl use strict; use warnings; my @columns = qw(col1 col2 col3); my @data = (); while (<DATA>) { chomp; my %tmp; @tmp{@columns} = split ','; push @data, \%tmp; } use Data::Dumper; print Dumper \@data; __DATA__ one,two,three four,five,six

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found