in reply to using an array in a regex

You will have to precompile your regex someplace before the conditon, basically like
# @a holds a list of string my @a = ("a", "b", "c", "/", "\[", "\""); #create a regex that matches every element in the array my $re = do { qr/(@{[join ("|", map { quotemeta } @a)]})/ }; die "not a regex!" unless ref($re) eq "Regexp";
You can put that $re into your regex like so
#you don't need to escape ; ... $chosen_C !=~ /^\*.{36};$re;/ ...
or you can put the whole regex into the variable.
my $re = do { qr/^\*.{36};(@{[join ("|", map { quotemeta } @a)]});/ }; die "not a regex!" unless ref($re) eq "Regexp"; ... $chosen_C !=~ $re ...
Thanks to calin for the "@{[statement]}" trick.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.