Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: compare two arrays if both are equal and have same elements irrespective of their position

by jo37 (Deacon)
on Jun 16, 2021 at 18:35 UTC ( [id://11133930]=note: print w/replies, xml ) Need Help??


in reply to compare two arrays if both are equal and have same elements irrespective of their position

There are plenty of features in Test2::V0. To compare an array with an unordered list of its values, there are bags. You may do something like:

use Test2::V0; my $have = [qw(c a b)]; is $have, bag {item $_ for qw(a b c); end}, 'matches'; isnt $have, bag {item $_ for qw(a a b c); end}, 'missing dup'; isnt $have, bag {item $_ for qw(a b); end}, 'one to much'; isnt $have, bag {item $_ for qw(a b c d); end}, 'one missing';

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
  • Comment on Re: compare two arrays if both are equal and have same elements irrespective of their position
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133930]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found