in reply to force regular expression to match every item only once

Not solving your problem but you could avoid the @{[join "|", @pairs]} by using the fact that regexen act like double quotes when interpolating arrays and changing the default list separator ($").

my $matcher = do { local $" = q{|}; qr{(?=(@pairs))}; };

Also, you can avoid having to escape the double quotes in your print statements when you want to interpolate by using quoting constructs (qq{...} for double quotes).

$ perl -e ' > @arr = qw{a b c}; > print qq{"@arr"\n};' "a b c" $

I hope these points are useful.

Cheers,

JohnGG