Hello Monks,
I need a hash that points to an of Array of Arrays data struct. The data struct looks ok but the hash data itself is wrong. I am loading the first value in the record set in the other three positions.

How do I evaluate the existence data in this hash that contains an array of array?

Is there a more efficient way to load this data struct?

Recordset looks like the following:
334 Capped 28 5034366 16777215 + NULL NULL NULL 373 Capped 28 5034366 16777215 + NULL NULL NULL

This shows the current data struct. Notice that the data is the same in the arrays. This output is from Data::Dumper.
$VAR147 = '5034510'; $VAR148 = &#091 &#091 '308', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '308', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '308', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '308', 'Capped ', 210, 16777215, undef, undef &#093 ]

It should look like this:
$VAR147 = '5034510'; $VAR148 = &#091 &#091 '308', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '334', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '373', 'Capped ', 210, 16777215, undef, undef &#093, &#091 '291', 'Capped ', 210, 16777215, undef, undef &#093 ]


This is the code that loads the hash and array of arrays data struct. Something is wrong it loads only the first value in the recordset.

sub insert_carrier_values { my $array_ref = shift; my $hash_ref = shift; for my $aref (@$array_ref) { #element 3 in the Hash Key if ( $aref->[3] > 0 ) { #Load the Array of Array with all the records from the query with the +same element #3 if the Array does #not have something alreay there in postion 0 $hash_ref->{ $aref->[3] }[0] = [ $aref->[0], $aref->[1], $aref->[2], $aref->[4], $aref->[5], $aref->[6] ] unless defined( $rank{ $aref->[3] }->[0][0] ); # Same as above but now load postion # 1 if postion 0 if full $hash_ref->{ $aref->[3] }[1] = [ $aref->[0], $aref->[1], $aref->[2], $aref->[4], $aref->[5], $aref->[6] ] unless defined( $rank{ $aref->[3] }->[1][0] ); # Same as above but now load postion # 2 if postion 1 if full $hash_ref->{ $aref->[3] }[2] = [ $aref->[0], $aref->[1], $aref->[2], $aref->[4], $aref->[5], $aref->[6] ] unless defined( $rank{ $aref->[3] }->[2][0] ); # Same as above but now load postion # 3 if postion 2 if full $hash_ref->{ $aref->[3] }[3] = [ $aref->[0], $aref->[1], $aref->[2], $aref->[4], $aref->[5], $aref->[6] ] unless defined( $rank{ $aref->[3] }->[3][0] ); } } } # end sub insert_carrier_values

In reply to Loading of Complex Data Structures by vegasjoe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.