if ($string =~ /${\(TEST)}/) { #### use constant PATTERN => qr/def/; if ($string =~ PATTERN) { ... } #### use constant PATTERN => 'def'; my $regex = qr/${\(PATTERN)}/; #options such as /m can go here. if ($string =~ regex) { ... }