perlcritic is complaining with Expression form of "eval" [BuiltinFunctions::ProhibitStringyEval] on the first eval line from the code below:
use strict;
use warnings;
use feature qw/say/;
my $hasTwitter = 1;
my $validEmail = 0;
my $rule = '${hasTwitter} | ${validEmail}';
my $result = eval $rule;
say "Result -> $result";
$result = eval { $rule };
say "Result -> $result";
I tried to use eval {} to fix the perlCritic but then It does not return the expected result.
The response is:
Result -> 1
Result -> ${hasTwitter} | ${validEmail}
Is there a workaround using the string interpolation? The idea is to have a set of rules on a configuration file and let the code read and eval them.
Thanks