my $re = do { local $" = '|'; qr/@array/; }; if ($bigstring =~ /$re/ ) { #... }