in reply to Re: Strange "undefined value as an ARRAY reference" error
in thread Strange "undefined value as an ARRAY reference" error

The OP is right. If you use a variable in a Perl regexp block, and that variable is defined outside the regexp, it's gotta be a package variable. Regexps acts as captures when they are compiled.
sub foo { my ($x) = @_; '' =~ /(?{ print "$x\n" })/; } foo('a'); foo('b');
Variable "$x" will not stay shared at (re_eval 1) line 2. a a

The warning was added in 5.10, but the problem has always existed.

However, the OP should have localized the variables. Bonus, this initializes @common_letters to ().

local our @common_letters; local our @wordsCopy = @words;