问题描述
我想分配给 perl 模块中的变量 $run
并检查 if 条件。
基本上,$run
变量被分配了当前工作目录的最后一个值,如果 perl 脚本正在检查分配给变量 $run
已发现确切问题的 perl 模块代码脚本片段的一部分。
ex.pm
-----
my $run = ${PWD##*/};
if ( $2 ne $run)
{
die "$0 should be run in a $run directory.";
}
使用此代码,我遇到了编译问题。如果直接将 if 条件与最后一个路径值硬编码其工作良好 if ( $2 ne '4')
。
编译问题消息
syntax error at bin/ex.pm line 44,near ")
{"
syntax error at bin/ex.pm line 49,near "$sitepath "
BEGIN not safe after errors--compilation aborted at bin/TestConstants.pm line 72.
Compilation failed in require at bin/ex1.pm line 13.
BEGIN failed--compilation aborted at bin/ex1.pm line 13.
Compilation failed in require at ./bin/test.pl line 26.
BEGIN failed--compilation aborted at ./bin/test.pl line 26 (#1)
(F) Probably means you had a syntax error. Common reasons include:
A keyword is misspelled.
A semicolon is missing.
A comma is missing.
An opening or closing parenthesis is missing.
An opening or closing brace is missing.
A closing quote is missing.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)