in reply to what does this code do?

Have you looked at what the code returns?

It merely quotes a string. It could have been written as

my $perl5patt = "(??{join q{|}, $quotemeta \@{$var_name}})";

I don't know where that string will be used, but it looks like it will be used in a regular expression and will try to match one or more words that are stored in the variable named by $var_name.

Personally I think that it should be faster to (re)build the regular expression on each change of @$var_name, but I don't know what code you have that necessitates executing code when trying to match something. The documentation for the ??{} construct lives in perlre