While digging in some old source code, I saw the following:
my $module = $some{module};
eval "require $module";
die "Bad module\n$@" if $@;
as long as I understand what the code does, it tries to βrequireβ the module and die when it is unsuccessful - perlcritic complains about it
The form of the expression "eval" is on line 331, column 13. See page 161 of PBP. (Severity level: 5)
Unfortunately, I don't have a PBP book, so I wonder what is the correct method above ...
Also in the same source found:
sub test_repo_file {
my($self, $repo, $test) = @_;
my $abspath = repo_abs_path($repo);
return "eval -$test $abspath";
}
It is not clear what "eval" solves, and perlcritic complains again about "string eval" ...
Can someone explain the main points about "string eval" and how to write above correctly?
source
share