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

You can use Test::Deep::NoTest to import functions from Test::Deep without interacting with tests.

#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use List::Util qw(shuffle); use Test::Deep::NoTest qw{ eq_deeply bag }; my @array1 = shuffle(1..100); my @array2 = shuffle(@array1); say eq_deeply(\@array1, bag(@array2)); # 1
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re: compare two arrays if both are equal and have same elements irrespective of their position
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: compare two arrays if both are equal and have same elements irrespective of their position
by jo37 (Curate) on Jun 16, 2021 at 20:55 UTC

    Do you know a way to create a bag using Test2::V0 as easy as in your example? I've been searching for something like that without luck.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      You can write a simple helper sub yourself (or maybe write many of them and upload them to CPAN):
      use Test2::V0; sub mybag { my @ar = @_; bag { item $_ for @ar ; end } } is(\@array1, mybag(@array2));
      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]