Rather than 'Global symbol "@array of lists" requires explicit package name...' I get the error 'Global symbol "$array_of_lists" requires explicit package name...'. When you reference the index in your loops, you are referencing it as a reference to a hash and not the hash itself. (ie $var->{$a} for a reference, $var{$a} for a hash). There was also an index typo fixed below. On the other hand, when selecting an array element, use [] instead of {}.

Update

my %array_of_lists = (1 => \@list3, 2 => \@list4, 3 => \@list899); #my @array_of_lists = (@list3, @list4, @list899); ##Set my hand my $my_pocket = "AcAs"; #printf("\n\n@array_of_lists\n\n"); #My cards my $my_card1 = substr($my_pocket, 0, 2); my $my_card2 = substr($my_pocket, 2, 2); printf("$my_pocket"); #for (my $z = 0; $z <= 100; $z++ #{ for my $a ( 0 .. scalar(keys %array_of_lists)) { #The loop will iterate through each element (hand of current h +andlist) of the current row and remove any #hand that contains the cards assigned randomly above. for my $b ( 0 .. $#{$array_of_lists{$a}} ) { #If the first card of the random hand above equal the firs +t card in the element I am currently on, then remove the element from + this handlist by #splicing it out. Or if the first card of the random hand +above equal the second card of the element (hand) I am currently spli +ce it out. if (substr($my_pocket, 0, 2) eq substr($array_of_lists{$a} +[$b], 0, 2) || substr($my_pocket, 0, 2) eq substr($array_of_lists{$a} +[$b], 2, 2)) { $array_of_lists{$a} = splice(@{$array_of_lists{$a}}, $ +b, 1); } elsif (substr($my_pocket, 2, 2) eq substr($array_of_lists{ +$a}[$b], 0, 2) || substr($my_pocket, 2, 2) eq substr($array_of_lists{ +$a}[$b], 2, 2)) { $array_of_lists{$a} = splice(@{$array_of_lists{$a}}, $ +b, 1); } } }

In reply to Re: working with hashes of arrays by kennethk
in thread working with hashes of arrays by gman1983

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.