perl -E 'our @array = (1,2,3); *1=\@array; say for @1;' 1 2 3 #### # $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 #### # $1[0] is seen as interpolation, placing the value of "1" into the regexp, which matches with the "1" in our target string. perl -E 'our @array = (1,2,3); *1=\@array; say for @1; say "yes" if "1" =~ m/.?$1[0]/;' 1 2 3 yes