in reply to Array within regexp?
Another way is to change the default list separator to the pipe symbol and interpolate the array into a compiled regular expression.
my @titles = qw{ Mr Mrs Ms Miss Dr Sir Lord Lady }; my $titlesRegex = do{ local $" = q{|}; qr{^(@titles)\s+(.*)} }; if( $text =~ $titlesRegex ) { print qq{$1 => $2\n}; }
Cheers,
JohnGG
|
|---|