Dear Monks,

I have an array and I would like to get understanding of how to compare each of the element with other matched elememts of the array.

this is my text file: textfile line1: 1 => A B C D E F G textfile line2: 2 => B F G textfile line3: 3 => D E F textfile line4: 4 => A C textfile line5: 5 => A D E F G textfile line6: 6 => G
Depending pon the number of matches, I wold like to print the output in following way:
1 => A B C D E F G 5 => A D E F G #(Since, there are 5 matches in the above array..and th +e order decreases depending pon the matches) 2 => B F G 3 => D E F 4 => A C 6 => G
Here is my attempted code:
#########################
while(<F1IN>) { chomp; $_ =~ /(.*)\s+\=\+\s+(.*)/; $number = $1; $values = $2; #I am creating an array here @array = split " ", $2; #here I am creating a reference to the hash**@AOA is now refer +ence to the original @array push @AOA, [@array]; } for $i ( 0 .. $#AOA ) { for $j ( 0 .. $#{ $AOA[$i] } ) { print "## $i $j is $AOA[$i][$j]\n"; } }
#The result is:
## 0 0 is A ## 0 1 is B ## 0 2 is C ## 0 3 is D ## 0 4 is E ## 0 5 is F ## 0 6 is G ## 1 0 is A ## 1 1 is D ## 1 2 is E ## 1 3 is F ## 1 4 is G ## 2 0 is B ## 2 1 is F ## 2 2 is G ## 3 0 is D ## 3 1 is E ## 3 2 is F ## 4 0 is A ## 4 1 is C ## 5 0 is G
############

I would be thankful if any of the monks can clear me the concept of using indices for comparing arrays.

To be clear, I want to check: for example, if index 0 0 is equal to 1 0, and if yes, check if 0 0 is eqaul to 1 1 and so on..

Thank you.
Neeli


In reply to comparing the elements of an array by young_perl_learner22

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.