相关疑难解决方法(0)

多线搜索替换为Perl

我知道这种问题之前已经被问过很多次了.我再次来到这里的原因是我觉得我错过了简单而基本的东西.

是否有可能更好地进行这种搜索替换程序.例如,两次不打开相同的文件.欢迎速度相关的建议.

请注意,这适用于多行匹配并替换多行字符串.

#!/bin/perl -w -0777

local $/ = undef;

open INFILE, $full_file_path or die "Could not open file. $!";
$string =  <INFILE>;
close INFILE;

$string =~ s/START.*STOP/$replace_string/sm;

open OUTFILE, ">", $full_file_path or die "Could not open file. $!";
print OUTFILE ($string);
close OUTFILE;
Run Code Online (Sandbox Code Playgroud)

perl

56
推荐指数
2
解决办法
6万
查看次数

标签 统计

perl ×1