in reply to Re^3: Array of hashes reference problem
in thread Array of hashes reference problem
Can't use string ("") as a HASH ref while "strict refs" in use at test-hash.pl line 19
Line 19 contains $arrayAoH$j{$key} = $value;
Thoughts?
Thanks! tl
#!/usr/bin/perl -w use strict; my @arrayAoH = ""; my $out = "First one: one Second one: second"; my @discovered = split /\n/, $out; my $i = 0; # i holds the line number of the input (@discovered) ar +ray. my $j = 0; # j holds the number of the table row. my $key; my $value; # $# returns the subscript of the last element in the array. until ($i eq $#discovered){ if ($discovered[$i] =~ m/First one:/){ # parse this line containing labels and values until a blank line is f +ound until ($discovered[$i] eq ""){ ($key, $value) = split /:\s*/, $discovered[$i]; ## $arrayAoH[$j] = { $key => $value }; $arrayAoH[$j]{$key} = $value; $i++; } $j++; } else { $i++;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Array of hashes reference problem
by sapnac (Beadle) on Jun 22, 2005 at 20:32 UTC | |
by tlemons (Novice) on Jun 22, 2005 at 21:30 UTC | |
|
Re^5: Array of hashes reference problem
by djohnston (Monk) on Jun 22, 2005 at 20:29 UTC |