use strict; my @FILES=("ABC","DEF","GHI","JKL","MNO","PQR","STU"); my %have_file = map { $_ => 1 } @FILES; if ($have_file{ABC} and $have_file{GHI} and $have_file{MNO} ) { # do something } else { # do something else }