The syntax appears to be thornier than what I am imagining.
I have the situation where the same regular expressions are needed throughout the code. To prevent future errors, it would be good to centralize the expression such that changes only need to be made once (and know about it...). The following code is syntactically incorrect, so what do I need to do in order to get the desired result?
Any insight would be appreciated
#!/bin/env perl
use constant REGEX => qr/cat/;
my $s = 'The cat in the hat...';
if ($s =~ /REGEX/) {
print "found\n";
}
else {
print "not found\n";
}