Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Identical Arrays

by Kenosis (Priest)
on Aug 26, 2012 at 06:33 UTC ( #989792=note: print w/replies, xml ) Need Help??


in reply to Identical Arrays

Another option is to use Array::Compare, as it can handle alpha, numeric and alphanumeric array data:

use Modern::Perl; use Array::Compare; my @a = ( 1, 2, 3 ); my @b = ( 2, 3, 1 ); my @c = ( 1, 2, 4 ); my @d = qw/ a b c a /; my @e = qw/ a a b c /; my @f = qw/ 1 b c 1 /; my @g = qw/ 1 1 b c /; say 'The arrays are', ArraysIdentical( \@a, \@b ) ? ' ' : ' not ', 'id +entical.'; sub ArraysIdentical { Array::Compare->new()->perm( $_[0], $_[1] ) || 0; }

Output:

The arrays are identical.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989792]
help
Chatterbox?
[Happy-the-monk]: Good lunchtime!
marto waves

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2017-11-19 11:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (279 votes). Check out past polls.

    Notices?