in reply to using an array in a regex

To answer your second question first (because it is well stated and understandable): it should be !~

Your main question is unclear. Can you post a self contained code fragment that demonstrates the problem you are trying to solve? Do you mean that you want to concatentate a number of strings to generate one big string to match, or do you want the match to succeed if any of a number of strings match (!~ seems unlikely in that case), or do you mean that you wish to select one array element as the match string?

Here's some code illustrating the last case:

use strict; use warnings; my $chosen = 'some text'; my @array = (qr'some', qr'more', qr'text'); my $index = 1; if (defined $chosen && $chosen !~ /$array[$index]/) { print "\$array[$index] matches\n"; }

DWIM is Perl's answer to Gödel