This is the first time that I have attempted to use complex data structures in Perl, and I bet I have made some small mistake. Below is what I believe is the significant code, from structure declaration to the attempted assignment. I have diagnostics and strict on.
my %member_info = ( mid=>undef, created_info=>{created_by=>undef, created_date=>undef,}, modified_info=>{modified_by=>undef, modified_date=>undef,}, person=>[ 0=>{salutation=>undef, first_name=>undef, middle_initial=> +undef, last_name=>undef, date_of_birth=>undef, primary_language=>unde +f, secondary_language=>undef, marital_status=>undef, working=>undef, + family_size=>undef, home_days=>undef, leader=>undef, default=>undef, +}, ], school=>[ 0=>{school_type=>"school", school_name=>undef, gradua +tion_date=>undef}, 1=>{school_type=>"school1", school_name=>undef, gradu +ation_date=>undef}, ], ); # declaring it just so I don't forget $response = $browser->get("https://infoishere.org/tails.asp?" . $_ +) if m/^\d+$/; $toke_parse = HTML::TokeParser->new( \$response->content ); #tokeparse full document, fill structure with data while($token = $toke_parse->get_token){ #match the table id's to start per-table loops next unless ($token->[0] eq 'S' and $token->[1] eq 'table'); # +only test table start tokes, skip other tokes if(($token->[0] eq "S") and ($token->[4] =~ m/id.{1,3}table13/ +i)){ #member unique id and name $token = $toke_parse->get_token until(($token->[0] eq "E") and + ($token->[1] =~ m/tr/i)); # end header row #debugging print Dumper(\%member_info); $member_info{'person'}[0]{'salutation'} = &skip_to_cell_text( +1 ); # error on this line $member_info{'person'}[0]{'first_name'} =&skip_to_cell_text( 1 + ); $member_info{'person'}[0]{'middle_initial'} = &skip_to_cell_te +xt( 1 ); [...]
The Dump:
$VAR1 = { 'modified_info' => { 'modified_date' => undef, 'modified_by' => undef }, 'created_info' => { 'created_date' => undef, 'created_by' => undef }, 'person' => [ 0, { 'middle_initial' => undef, 'salutation' => undef, 'leader' => undef, 'marital_status' => undef, 'date_of_birth' => undef, 'last_name' => undef, 'family_size' => undef, 'primary_language' => undef, 'default' => undef, 'secondary_language' => undef, 'home_days' => undef, 'first_name' => undef } ], 'school' => [ 0, { 'graduation_date' => undef, 'school_name' => undef, 'school_type' => 'school' }, 1, { 'graduation_date' => undef, 'school_name' => undef, 'school_type' => 'school1' } ], 'mid' => undef };


The error:
Can't use string ("0") as a HASH ref while "strict refs" in use at ./prog line 136 (#1)
(F) Only hard references are allowed by "strict refs". Symbolic references are disallowed. See perlref.

The Mystery:
It looks like it is a hash that points to an array that contains a hash, and that is what I want. The 0 is an array ref, not a hash. Why is my assignment causing an error?

In reply to Mistake in data structure use? by McLogic

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.