Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

compare 2 arrays

by madM (Beadle)
on Aug 10, 2013 at 15:20 UTC ( [id://1048912]=perlquestion: print w/replies, xml ) Need Help??

madM has asked for the wisdom of the Perl Monks concerning the following question:

Hi people.. im trying to compare this 2 arrays and see if theres a difference and where.. any suggestions?
my @matrix =( 0.54, 0.03, 0.03, 0.03, 0.08, 0.04, 0.05, 0.05, 0.02, 0.02, 0.03, 0.04 +, 0.03, 0.01, 0.06, 0.11, 0.06, 0.01, 0.01, 0.06, 0.02, 0.57, 0.03, 0.01, 0.02, 0.06, 0.03, 0.01, 0.04, 0.01, 0.01, 0.11 +, 0.02, 0.01, 0.01, 0.02, 0.02, 0.01, 0.01, 0.01, 0.01, 0.02, 0.48, 0.06, 0.01, 0.03, 0.03, 0.03, 0.05, 0.01, 0.01, 0.03 +, 0.01, 0.00, 0.01, 0.04, 0.03, 0.00, 0.02, 0.01, 0.02, 0.01, 0.09, 0.57, 0.01, 0.04, 0.11, 0.02, 0.03, 0.00, 0.00, 0.03 +, 0.01, 0.00, 0.02, 0.04, 0.02, 0.00, 0.01, 0.00, 0.01, 0.00, 0.00, 0.00, 0.57, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 +, 0.00, 0.01, 0.00, 0.01, 0.01, 0.01, 0.01, 0.01, 0.02, 0.04, 0.03, 0.02, 0.01, 0.42, 0.05, 0.01, 0.04, 0.01, 0.01, 0.05 +, 0.02, 0.00, 0.01, 0.02, 0.02, 0.01, 0.01, 0.01, 0.04, 0.04, 0.05, 0.13, 0.01, 0.11, 0.52, 0.02, 0.03, 0.01, 0.01, 0.07 +, 0.01, 0.00, 0.02, 0.04, 0.04, 0.01, 0.01, 0.01, 0.05, 0.02, 0.05, 0.03, 0.02, 0.02, 0.02, 0.77, 0.02, 0.00, 0.00, 0.02 +, 0.01, 0.00, 0.01, 0.04, 0.01, 0.01, 0.00, 0.01, 0.01, 0.01, 0.02, 0.01, 0.01, 0.02, 0.01, 0.00, 0.54, 0.00, 0.00, 0.01 +, 0.01, 0.02, 0.01, 0.01, 0.01, 0.02, 0.04, 0.00, 0.02, 0.01, 0.01, 0.00, 0.03, 0.01, 0.01, 0.00, 0.01, 0.50, 0.10, 0.01 +, 0.09, 0.04, 0.01, 0.01, 0.03, 0.02, 0.01, 0.18, 0.03, 0.02, 0.01, 0.01, 0.03, 0.03, 0.01, 0.00, 0.02, 0.13, 0.60, 0.02 +, 0.19, 0.09, 0.02, 0.02, 0.02, 0.02, 0.03, 0.08, 0.03, 0.14, 0.06, 0.03, 0.01, 0.09, 0.06, 0.02, 0.05, 0.01, 0.01, 0.50 +, 0.02, 0.01, 0.02, 0.04, 0.03, 0.01, 0.01, 0.01, 0.01, 0.01, 0.00, 0.00, 0.01, 0.02, 0.00, 0.00, 0.01, 0.03, 0.05, 0.01 +, 0.42, 0.02, 0.00, 0.01, 0.01, 0.01, 0.01, 0.02, 0.01, 0.01, 0.00, 0.00, 0.02, 0.01, 0.00, 0.00, 0.03, 0.02, 0.04, 0.00 +, 0.04, 0.61, 0.00, 0.01, 0.01, 0.07, 0.14, 0.01, 0.03, 0.01, 0.01, 0.01, 0.00, 0.01, 0.01, 0.01, 0.02, 0.00, 0.01, 0.01 +, 0.01, 0.00, 0.72, 0.03, 0.01, 0.00, 0.00, 0.01, 0.07, 0.03, 0.06, 0.04, 0.05, 0.04, 0.03, 0.03, 0.02, 0.01, 0.01, 0.04 +, 0.02, 0.01, 0.04, 0.43, 0.09, 0.02, 0.01, 0.01, 0.04, 0.02, 0.04, 0.02, 0.04, 0.03, 0.03, 0.01, 0.02, 0.02, 0.02, 0.03 +, 0.03, 0.01, 0.02, 0.09, 0.52, 0.01, 0.01, 0.04, 0.00, 0.00, 0.00, 0.00, 0.01, 0.00, 0.00, 0.00, 0.01, 0.00, 0.00, 0.00 +, 0.00, 0.02, 0.00, 0.00, 0.00, 0.71, 0.02, 0.00, 0.00, 0.01, 0.01, 0.00, 0.01, 0.01, 0.00, 0.00, 0.05, 0.01, 0.01, 0.01 +, 0.01, 0.10, 0.00, 0.01, 0.01, 0.06, 0.61, 0.01, 0.05, 0.01, 0.01, 0.01, 0.07, 0.02, 0.02, 0.01, 0.01, 0.20, 0.07, 0.01 +, 0.06, 0.03, 0.01, 0.02, 0.06, 0.02, 0.02, 0.51); my @array2=qw( 0.54 0.03 0.03 0.03 0.08 0.04 0.05 0.05 0.02 0.02 0.03 0.04 0.03 0.01 +0.06 0.11 0.06 0.01 0.01 0.06 0.02 0.57 0.03 0.01 0.02 0.06 0.03 0.01 0.04 0.01 0.01 0.11 0.02 0.01 +0.01 0.02 0.02 0.01 0.01 0.01 0.01 0.02 0.48 0.06 0.01 0.03 0.03 0.03 0.05 0.01 0.01 0.03 0.01 0.00 +0.01 0.04 0.03 0.00 0.02 0.01 0.02 0.01 0.09 0.57 0.01 0.04 0.11 0.02 0.03 0.00 0.00 0.03 0.01 0.00 +0.02 0.04 0.02 0.00 0.01 0.00 0.01 0.00 0.00 0.00 0.57 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.01 +0.00 0.01 0.01 0.01 0.01 0.01 0.02 0.04 0.03 0.02 0.01 0.42 0.05 0.01 0.04 0.01 0.01 0.05 0.02 0.00 +0.01 0.02 0.02 0.01 0.01 0.01 0.04 0.04 0.05 0.13 0.01 0.11 0.52 0.02 0.03 0.01 0.01 0.07 0.01 0.00 +0.02 0.04 0.04 0.01 0.01 0.01 0.05 0.02 0.05 0.03 0.02 0.02 0.02 0.77 0.02 0.00 0.00 0.02 0.01 0.00 +0.01 0.04 0.01 0.01 0.00 0.01 0.01 0.01 0.02 0.01 0.01 0.02 0.01 0.00 0.54 0.00 0.00 0.01 0.01 0.02 +0.01 0.01 0.01 0.02 0.04 0.00 0.02 0.01 0.01 0.00 0.03 0.01 0.01 0.00 0.01 0.50 0.10 0.01 0.09 0.04 +0.01 0.01 0.03 0.02 0.01 0.18 0.03 0.02 0.01 0.01 0.03 0.03 0.01 0.00 0.02 0.13 0.60 0.02 0.19 0.09 +0.02 0.02 0.02 0.02 0.03 0.08 0.03 0.14 0.06 0.03 0.01 0.09 0.06 0.02 0.05 0.01 0.01 0.50 0.02 0.01 +0.02 0.04 0.03 0.01 0.01 0.01 0.01 0.01 0.00 0.00 0.01 0.02 0.00 0.00 0.01 0.03 0.05 0.01 0.42 0.02 +0.00 0.01 0.01 0.01 0.01 0.02 0.01 0.01 0.00 0.00 0.02 0.01 0.00 0.00 0.03 0.02 0.04 0.00 0.04 0.61 +0.00 0.01 0.01 0.07 0.14 0.01 0.03 0.01 0.01 0.01 0.00 0.01 0.01 0.01 0.02 0.00 0.01 0.01 0.01 0.00 +0.72 0.03 0.01 0.00 0.00 0.01 0.07 0.03 0.06 0.04 0.05 0.04 0.03 0.03 0.02 0.01 0.01 0.04 0.02 0.01 +0.04 0.43 0.09 0.02 0.01 0.01 0.04 0.02 0.04 0.02 0.04 0.03 0.03 0.01 0.02 0.02 0.02 0.03 0.03 0.01 +0.02 0.09 0.52 0.01 0.01 0.04 0.00 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.01 0.00 0.00 0.00 0.00 0.02 +0.00 0.00 0.00 0.71 0.02 0.00 0.00 0.01 0.01 0.00 0.01 0.01 0.00 0.00 0.05 0.01 0.01 0.01 0.01 0.10 +0.00 0.01 0.01 0.06 0.61 0.01 0.05 0.01 0.01 0.01 0.07 0.02 0.02 0.01 0.01 0.20 0.07 0.01 0.06 0.03 +0.01 0.02 0.06 0.02 0.02 0.51);

Replies are listed 'Best First'.
Re: compare 2 arrays
by BrowserUk (Patriarch) on Aug 10, 2013 at 16:00 UTC

    $matrix[ $_ ] == $array2[ $_ ] or warn "$_: $matrix[ $_ ] != $array2[ +$_ ]" for 0 .. $#matrix;

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: compare 2 arrays
by toolic (Bishop) on Aug 10, 2013 at 15:26 UTC
Re: compare 2 arrays
by BillKSmith (Monsignor) on Aug 10, 2013 at 19:06 UTC
    Either method that has been suggested will tell you if the two arrays are the same. If not, they have a very different way of describing the difference. I would like to know which one better fits your needs.
    Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1048912]
Approved by Happy-the-monk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (None)
    As of 2024-04-25 01:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found