Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by gopalr (Priest)
on Mar 31, 2006 at 09:50 UTC ( [id://540425] : note . print w/replies, xml ) Need Help??


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

Hi tsk1979 ,

There is a module List::Compare will do that work.

use strict; use warnings; use List::Compare; my @a = qw(-true -depth=1); my @b = qw(-search -depth=1 -true -expand_all) ; my $lc = List::Compare->new( \@a, \@b ); my @a_only = $lc->get_Lonly; my @b_only = $lc->get_Ronly; print join( ', ', @a_only ), "\n"; # 1, 2 @a_only ? print "@a_only" : print "\nAll Matched";