The script should start like this:
#!/usr/bin/perl -w use strict;
(note the initial "#!")

You have a $AoA[$x1][$y1] in there, but I think this should either be "RAM" or "RAM1" instead of "AoA".

Pushing values of $y1 onto a @shyam array seems pointless -- if you want to keep track of where the mismatches are, you probably want to save $x1 as well as $y1.

You seem to be building an array of hashes in @inde, but each hash only has one key/value pair, with "$y1" as the hash key. Are you planning on adding more key/value things later? If not, you might as well be pushing plain old strings onto a plain old array. (Maybe you really want "inde" to be a HoH, keyed by $x1 and $y1 ?)

It's not clear what sort of result you really want as your output, and you didn't provide any sample input, so I'm not sure what else to say about the code, except that it could be written in a way that would be easier to read (and you can probably use sprintf to get the string format that you want for @inde):

# ... after declaring and loading values into @RAM and @RAM1... my %inde; my $rownum = 0; for my $row ( @RAM ) { my $row1 = $RAM1[$rownum]; my $colnum = 0; for my $col ( @$row ) { if ( $col ne $row1->[$colnum] ) { printf( "Mismatch at row %d col %d: RAM=%s vs. RAM1=%s\n" +, $rownum, $colnum, $col, $row1->[$colnum] ); $inde{$rownum}{$colnum} = sprintf( "%17s | %-17s", $col, $ +row1->[$colnum] ); } $colnum++; } $rownum++; } # do something with %inde...
If I were looking for diffs between a couple of 2-D arrays, that sort of how I would do it, I think.

In reply to Re: Finding Mismatches by graff
in thread Finding Mismatches by Abhisek

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.