swampyankee is correct. Here is some code that shows the principle:
use strict; use warnings; use Data::Dumper; use Digest::MD5 qw(md5); my %lookup; my @AoA = ( ["a", "b", "c"], ["d", "e", "f"], ["a", "b", "c"], ["g", "h", "i"], ["a", "b", "c"], ["g", "h", "i"], ); #Build a lookup hash from AoA, values of the hash will be #an arrayref to the positions where a given array was found my $index = 0; for ( @AoA ) { my $k = md5(Dumper($_)); push @{$lookup{$k}}, $index++; } $index = 0; #test data my @test = ( ["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"], ["x", "y", "z"], ); #loop tests for ( @test ) { print "Test ", $index++, ": ", join (", ", @{ref_exists($_)}), "\n +"; } #returns the positions or undef when the arrayref is not in AoA sub ref_exists { return $lookup{md5(Dumper(shift))} || []; }
Note that, because I use Data::Dumper for creating the digest, the technique should work for deep structures also, not just for plain arrays of strings.


holli, /regexed monk/

In reply to Re^3: Checking if an Array is a Member of an AoA by holli
in thread Checking if an Array is a Member of an AoA by neversaint

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.