我必须阅读&修改.lib文件中的某些数据。 我可以提取存在数据的行,但我无法提取与之关联的数字。
open my $fh, "<" ,".....lib" or die "$!";
while(my $line = <$fh>) {
if ($line =~ m/xyz0/) {
print $line;
}
}
代码输出行:
+xyz0 = 0.005 hg = 0.9 rvfd = 75
我想从中提取xyz0旁边的值。我该怎么做?
答案 0 :(得分:4)
if ($line =~ m/xyz0 = (\S+)/){
print $1;
}