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

Using a temporary hash and List::MoreUtils:

use List::MoreUtils qw(all); use strict; use warnings; my @partial = qw(-true -depth=1); my @complete = qw (-search -depth=1 -true -expand_all); my %temp; @temp{@complete} = @complete; print "Yep\n" if all { exists $temp{$_} } @partial;

All dogma is stupid.

Replies are listed 'Best First'.
Re^2: Finding wether all elements of one array are in another
by jdporter (Paladin) on Mar 31, 2006 at 12:58 UTC

    I don't think you need the module. Remember that all positive is the same as none negative.

    my %temp; @temp{@complete} = @complete; print "Yep\n" unless grep { ! exists $temp{$_} } @partial;
    We're building the house of the future together.