Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Finding wether all elements of one array are in another

by Samy_rio (Vicar)
on Mar 31, 2006 at 09:24 UTC ( [id://540421]=note: print w/replies, xml ) Need Help??


in reply to Finding wether all elements of one array are in another

Hi tsk1979, Try this,

use strict; use warnings; use Array::Compare; my @ar1 = qw(-true -depth=1); my @ar2 = qw(-search -depth=1 -true -expand_all); my $comp = Array::Compare->new(); if ($comp->compare(\@ar1, \@ar2)){print "Same Array OK";}else{print " +Different Array OK";}

Updated davorg solution is correct. compare function compare the arrays in order.

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re^2: Finding wether all elements of one array are in another
by davorg (Chancellor) on Mar 31, 2006 at 09:48 UTC

    Looks like order isn't significant, so you might be better off using the perm method rather than the compare method.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found