Perl语法错误,但我一辈子都找不到它

发布于 2024-11-26 03:58:21 字数 1066 浏览 0 评论 0原文

这个错误让我很生气。我在这些行附近看不到任何有括号错误或缺少括号的内容。有人帮我一下吗?这是我的第一篇文章,如果格式不对,请原谅;我想我做对了。

编辑:第 87 行,');'错误,是这一行: select(SEXTANT_DAEMON_LOG);

syntax error at -edited- line 87, near ");"
syntax error at -edited- line 92, near "if"
syntax error at -edited- line 99, near "if"
Unmatched right curly bracket at -edited- line 102, at end of line
syntax error at -edited- line 102, near "}"
syntax error at -edited- line 109, near "}"
syntax error at -edited- line 120, near ");"
BEGIN not safe after errors--compilation aborted at -edited- line 122.

这是错误附近的代码(此处为完整代码):

$MAIN_DBH = getConnection('Main');
$fs_logfile = getCSConfigValue($MAIN_DBH, 'Log', 'Sextant Update Daemon') or die "pid$$[" . localtime(time()) . "] Main dbh error: " . DBI::errstr;
open(SEXTANT_DAEMON_LOG, '>>', $fs_logfile) or die "pid$$[" . localtime(time()) . "] unable to open log file '$fs_logfile'\n";
$tmp = select(SEXTANT_DAEMON_LOG);
$| = 1;
select(SEXTANT_DAEMON_LOG);

This error is angering me. I can't see anything near those lines with a parenthesis error or missing brackets. Someone give me a hand? This is my first post, forgive me if the formatting is off; I think I got it right.

EDIT: line 87, the ');' error, is this line: select(SEXTANT_DAEMON_LOG);

syntax error at -edited- line 87, near ");"
syntax error at -edited- line 92, near "if"
syntax error at -edited- line 99, near "if"
Unmatched right curly bracket at -edited- line 102, at end of line
syntax error at -edited- line 102, near "}"
syntax error at -edited- line 109, near "}"
syntax error at -edited- line 120, near ");"
BEGIN not safe after errors--compilation aborted at -edited- line 122.

This is the code near the error (full code here):

$MAIN_DBH = getConnection('Main');
$fs_logfile = getCSConfigValue($MAIN_DBH, 'Log', 'Sextant Update Daemon') or die "pid$[" . localtime(time()) . "] Main dbh error: " . DBI::errstr;
open(SEXTANT_DAEMON_LOG, '>>', $fs_logfile) or die "pid$[" . localtime(time()) . "] unable to open log file '$fs_logfile'\n";
$tmp = select(SEXTANT_DAEMON_LOG);
$| = 1;
select(SEXTANT_DAEMON_LOG);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿港巷口少年归 2024-12-03 03:58:21

Perl 没有给出很好的错误消息,但它实际上抱怨的是 "pid$$[" 看起来像是访问数组 @$ 的无效尝试。尝试将其替换为“pid$$\[”

我发现的方法是在附近插入 __END__报告的第一个错误的位置。我上下移动它,直到找到导致错误的第一行,

$fs_logfile = getCSConfigValue($MAIN_DBH, 'Log', 'Sextant Update Daemon') or die "pid$[" . localtime(time()) . "] Main dbh error: " . DBI::errstr;

然后我尝试添加反斜杠,它修复了错误。

注意: perl -c 非常有用在这种情况下很有用。

Perl isn't giving a very good error message, but what it's actually complaining about is that "pid$$[" looks like an invalid attempt to access the array @$. Try replacing it with "pid$$\[".

The way I found that was by inserting __END__ near the reported location of the first error. I moved it up and down until I found the first line that caused an error, which was

$fs_logfile = getCSConfigValue($MAIN_DBH, 'Log', 'Sextant Update Daemon') or die "pid$[" . localtime(time()) . "] Main dbh error: " . DBI::errstr;

Then I tried adding the backslash, and it fixed the error.

Note: perl -c is very useful in situations like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文