in reply to using an array in a regex

But what I really want to do is substitute $EXEC_block with ...... 'any element of the array: @EXEC_block'.

use Regexp::List (); $EXEC_block = Regexp::List->new->list2re(@EXEC_block); ...

Reference: Regexp::List

please explain to me why Perl does not allow !=~.

It's !($var =~ $re) or $var !~ $re.

Reference: perlop

Replies are listed 'Best First'.
Re^2: using an array in a regex
by blazar (Canon) on Jan 17, 2006 at 09:09 UTC

    Nice answer, and an informative one. In fact generally one does this by hand joining on "|" - and probably forgetting to \Q...\E (or quotemeta). However it is worth mentioning that the OP may also do like most mortals:

    for my $EXEC_block (@EXEC_block) { last if s/...//; # since we don't want to try again after we succeeded! }

    PS: shameless self ad - (slightly) related topic!