【发布时间】:2026-02-23 23:25:02
【问题描述】:
我正在按照 Perl - Formats 上的教程学习 Perl 格式化,但是当我在我的 IDE 中键入他们的示例时:
format EMPLOYEE =
===================================
@<<<<<<<<<<<<<<<<<<<<<< @<<
$name $age
@#####.##
$salary
===================================
.
select(STDOUT);
$~ = EMPLOYEE;
@n = ("Ali", "Raza", "Jaffer");
@a = (20,30, 40);
@s = (2000.00, 2500.00, 4000.000);
$i = 0;
foreach (@n) {
$name = $_;
$age = $a[$i];
$salary = $s[$i++];
write;
}
我得到错误:
Scalar found where operator expected at .\qb.pl line 7, near "$name $age"
(Missing operator before $age?)
syntax error at .\qb.pl line 7, near "$name $age"
Execution of .\qb.pl aborted due to compilation errors.
我正在使用为 MSWin32-x64-multi-thread 构建的 Perl 5,版本 30,Subversion 2 (v5.30.2)。
【问题讨论】: