I've got a situation where I need to build an array of hashes of arrays of hashes (complex, yes, but it really is needed!) I'm getting a weird error, though. Here's a sampling of code that throws the error:
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!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|