my ($n, $first, $last) = ($#$copy, @$copy[0,-1]); if ( ( $first == $n+1 || $first != max(@$copy[0..($first - 1)]) ) && ( $last == 1 || $last != min(@$copy[($last - 1)..$n]) )) { ...