Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 for 循环中读取多行并将它们拆分。之后我想对单个数组元素进行替换。
my @fs = split(';', $line); $fs[0] =~ s/\"//g;
然而,这不起作用。线
$fs[0] =~ s/\"//g;
返回编译器错误。
有一个更好的方法吗?
将行更改split为
split
my @fs = split(/;/, $line);
因为split将正则表达式作为其第一个操作数。
我怀疑您看到的解析错误是由于其他地方的错误造成的,因为您问题中代码的语法是正确的。
一般来说,总是修复解析器诊断出的第一个错误。好的解析器会尝试恢复以报告尽可能多的错误,但这个过程并不总是可靠的。您看到的错误的确切文本是什么?