GeoJunkie has asked for the wisdom of the Perl Monks concerning the following question:
my @array_of_hashes; for (my $i=1; $i<=10; $i++) { $array_of_hashes[$i] = ( stuff => 'stuffy', goes => 'gooey', here => "more $i" ); $array_of_hashes[$i]{sub_data}[6] = "seven"; }
When I execute this, I get: "Can't use string ("more 1") as a HASH ref while "strict refs" in use" at the last assignment operation ($array_of_hashes$i{sub_data}6 = "seven";). Any ideas why and how I can go about adding a hash with a subarray in this way?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subarray in a hash: Can't use string ("STRING") as a HASH ref while "strict refs" in use
by choroba (Cardinal) on Apr 08, 2014 at 13:39 UTC | |
by GeoJunkie (Initiate) on Apr 08, 2014 at 13:48 UTC | |
by choroba (Cardinal) on Apr 08, 2014 at 13:51 UTC | |
by shawnhcorey (Friar) on Apr 08, 2014 at 14:22 UTC | |
by andal (Hermit) on Apr 08, 2014 at 13:52 UTC | |
|
Re: Subarray in a hash: Can't use string ("STRING") as a HASH ref while "strict refs" in use
by AnomalousMonk (Archbishop) on Apr 08, 2014 at 17:58 UTC |