in reply to Re: parsing data pairs from single line
in thread parsing data pairs from single line

my $regex = '\b(' . join('|', @keywords) . ')\s((?:(?!(' . join('|', @keywords) . ')\b).)*)';

Rather than all the concatenation and the joins, you could take advantage of the double-quote-like behaviour of regexen by localising the list separator in a do block and interpolating @keywords.

my $regex = do { local $" = q{|}; qr{(?x) \b (@keywords) \s ( (?: (?! (@keywords) \b ) . )* ) } };

It looks a little clearer to my eye.

Cheers,

JohnGG