my $pat = gimme_pat(); # Some method returning a qr if ($str =~ /^ $pat $ # Anchor pattern/x) { ... }