#!/usr/bin/perl -w use strict; my @FirstArray = qw(one two three); my @SecondArray = qw(four seven one eight two nine three seventeen); unless (index ((join "" , sort map {"@FirstArray" =~ /\b($_)\b/;} @SecondArray) , (join "" , sort @FirstArray)) eq -1) { print "Second array contains all the elements in first array\n"; } else { print "Second array does not contain all the elements in the first array\n"; }