#!/usr/bin/env perl use strict; use warnings; my @allwords = qw( this is a list of words that is required for tests ); my @required = qw( this is a list of words that is required ); my %hash = map { $_ => 1 } @allwords; print "do stuff\n" if @required == grep { $_ } @hash{@required}; my @notthere = qw( this list is not there in allwords ); print "don't do stuff\n" unless @notthere == grep { $_ } @hash{@notthere};