【发布时间】:2015-06-24 01:32:53
【问题描述】:
Perl 新手在这里。我不明白为什么下面的代码不起作用:
use strict;
my $file = shift;
open(FRED,'<',$file);
while (my $line = <FRED>) {
if ($line ~= /(fred)/i) {
print("$line mentions fred.\n");
}
}
我不断收到以下错误:
syntax error at ./regex2.pl line 11, near "$line ~"
syntax error at ./regex2.pl line 14, near "}"
./regex.pl 的执行由于编译错误而中止。
【问题讨论】: