
liven
Novice
Mar 10, 2008, 1:47 PM
Post #1 of 3
(707 views)
|
accessing hash of arrays:
|
Can't Post
|
|
loading an array of hashes:
sub read_bingo_data { open (excel_data, $descriptive_file) || die("Couldn't open bingo description file\n"); @data_lines=<excel_data>; foreach $record (@data_lines) { @holder = split(/,/, $record); $bingo_name = shift(@holder); push@{$descriptive_hash->{'bingo'}{$bingo_name}},"@holder[1..4]"; } close(excel_data); } But when I try to step back through the array It only shows up as one element. I use this line:
@holder = split(/,/, $record); and I use this line:
$bingo_name = shift(@holder); to name the array in the hash. I need each array to be named the first (element[0]) of the array or line from the excel data... to add the data from an excell sheet to an array. but I don't need the first element of the array so that is why I do this:
push@{$descriptive_hash->{'bingo'}{$bingo_name}},"@holder[1..4]"; Everything works, except the line: @{$descriptive_hash->{'bingo'}{$bingo_name}},"@holder[1..4]" acts as if it is just one element not 4.... What did I do wrong? I want it to be 4 separate elements that I can iterate through.
|