I realize that your example is most likely reduced from something more interesting. However, in this case, another solution exists. Treat the constant as a regex (well a runtime-interpolated search pattern really) in stead of interpolating it into one. Example:
use constant NAME => 'abc'; # ... if ($input =~ NAME) { print "Matched!" }
In reply to Re: using constants in regex/search
by plobsing
in thread using constants in regex/search
by geniezlife
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |