my @numlist = (1,2,3,4,5); if (join (",", @numlist ) eq join (",", (1..$#numlist+1))) { print "correct"; } else { print "incorrect"; }