我希望在正则表达式匹配后删除该行,但我不确定如何编写删除Perl中的下一行 - 帮助?
while ( my $line = <FILE> ) {
if ($line =~ m/(regex)/i) {
# delete the next $line
}
Run Code Online (Sandbox Code Playgroud)
你是什么意思"删除"?你的意思是忽略它?
while ( my $line = <FILE> ) {
if ( $line =~ /regex/ ) { # If it matches this regex
my $ignored = <FILE>; # read the next line and ignore it.
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |