You can save yourself a lot of effort in posting by putting "<code>" at the beginning of your perl code, and "</code>" at the end.

Your "check_same" sub is written to use just two array refs as args, but you are calling it with a long list of arrays (not refs to arrays). The two calls you have to check_same should look like this:

print "\@D is not the same as \@E\n" unless check_same( \@D, \@E ); print "\@D is the same as \@F\n" if check_same( \@D, \@F );
Apart from that, you should probably make your sub definition simpler (skip the "(\@\@)" part), but check to make sure the args are refs to arrays:
sub check_same { my ( $ref1, $ref2 ) = @_; die "Bad args passed to check_array\n" unless ( ref( $ref1 ) eq 'ARRAY' and ref( $ref2 ) eq 'ARRAY' ) +; return 0 if @$ref1 != @$ref2; for my $i ( 0 .. $#$ref1 ) { return 0 if $$ref1[$i] ne $$ref2[$i]; } return 1; }
You might also consider the "carp" or "croak" methods provided in Carp, instead of "die", to handle those kinds of error conditions in a subroutine.

In reply to Re: compare and output to the screen by graff
in thread compare and output to the screen by coronalvrr

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.