我有一个 Perl 脚本,如下所示:
while ( <INPUT> ) {
if (condition) {
# match a string 3 lines down from current line
}
}
如何在输入中跳过行并基本上“查找下一个匹配行”?
最佳答案
您可能想从同一个文件句柄读取内容,并跳到第三行,
while ( <INPUT> ) {
if (condition) {
# match a string 3 lines down from current line
<INPUT> for 1..2;
$_ = <INPUT> // last; # eof?
}
}
关于regex - Perl 匹配输入中的下一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33599071/