更新时间:2022-11-13 23:22:15
sub replacer {
$line = shift;
$find = shift;
$replace = shift;
$line =~ /([^:]+):/
if ($1 =~ /$find/) {
$line =~ s/([^:]+):/$replace/ ;
return $line;
}
return ;
}
while (<IN>)
{
print OUT replacer ($_,"mean","variance");
print OUT replacer ($_,"pattern","newPattern");
}
我的 perl 有点生疏,所以语法可能不准确.
My perl is a little rusty, so syntax might not be exact.
编辑:把它放在一个函数中.
edit: Put it in a function for ya.