perl -le '@x = qw(a b c d e f); @y = qw(a d f); $n = grep { $e = $_; not grep { $e =~ /\Q$_/i } @x } @y; print "Count of elements in (@y) that are NOT present in (@x) = $n" ' Count of elements in (a d f) that are NOT present in (a b c d e f) = 0 #### ____DATA_____ b c a a c d d e b e f g g d f h i g #### a b c a b d c e f d g #### component 1 = a b c induced = b c a component = a b d c induced = b c a a c d component 3 = e f d g induced = e f g g d f