# $1 will be undef, so not relevant to the pattern. [0] will be a single-character character class, so matches "0". perl -E 'our @array = (1,2,3); *1=\@array; say for @1; say "yes" if "0" =~ m/.?${1}[0]/;' 1 2 3 yes