barakuda has asked for the wisdom of the Perl Monks concerning the following question:
But when I try to print something like print $data[0]{COMPONENT} Perl complains that "string "Component " cannot be used as a HASH reference". I think the problem is in how I populate the array. Any ideas? Thank you.sub read_dat { my @data = (); open (IN, "<Weekly_Data.csv") or die "ERROR: Could not open weekly + data file!"; foreach my $line (<IN>){ my @line = split (",", $line); my $i = 0; my %tmp; foreach my $col (@columns){ $tmp{$col} = $line[$i]; $i++} push (@data, %tmp); } close (IN); return @data; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array of Hashes population
by Anonymous Monk on Mar 06, 2008 at 16:56 UTC | |
by barakuda (Initiate) on Mar 06, 2008 at 17:04 UTC | |
by swampyankee (Parson) on Mar 06, 2008 at 17:37 UTC | |
|
Re: Array of Hashes population
by dwm042 (Priest) on Mar 06, 2008 at 18:25 UTC | |
by TGI (Parson) on Mar 06, 2008 at 19:56 UTC | |
|
Re: Array of Hashes population
by Roy Johnson (Monsignor) on Mar 06, 2008 at 17:10 UTC | |
|
Re: Array of Hashes population
by EvanCarroll (Chaplain) on Mar 06, 2008 at 17:32 UTC |