in reply to On the regex pattern variable to be inserted into another

I suspect that you have a regex with a fixed a variable part.
use strict; use warnings; my $string = 'title: ABC_II'; foreach my $index (qr/I/, qr/II/, qr/III/) { print "Match\n" if $string =~ m/ABC_$index/; }

You want to know if you can speed it up by pre-compiling the fixed part.

use strict; use warnings; my $string = 'title: ABC_II'; my $fixed = qr/ABC_/; foreach my $index (q(I II III)) { print "Match\n" if $string =~ m/$fixed$index/; }

Clearly the syntax is allowed. You would have to benchmark your case to find out if and how much it helps.

Bill