新手第一次发帖请多包涵,求教perl中s///的使用问题,希望得指教
我写了段程序,希望能将正则匹配表达式所匹配的结果中对应的标签替换成我计算过的标量,写的程序如图。出现死循环无限报错,求教正确的使用方法。
作者: jsftd 发布时间: 2011-05-20
作者: jsftd 发布时间: 2011-05-20
$Xrecord =($nowrecord+$lastrecord)/2;
$XUx =($nowUx+$lastUx)/2;
$XUy =($nowUy+$lastUy)/2;
$XUz =($nowUz+$lastUz)/2;
$Xco2 =($nowco2+$lastco2)/2;
$Xh2o =($nowh2o+$lasth2o)/2;
$XTs =($nowTs+$lastTs)/2;
$Xpress =($nowpress+$lastpress)/2;
while(defined(@rray)){
$newarray = shift @rray;
$newarray =~ (s|(?<date>"\d\d\d\d-\d\d-\d\d\s*\d\d:\d\d:\d\d.?\d?") (?<record>\d+) (?<Ux>-?\d+\.\d+) (?<Uy>-?\d+\.\d+) (?<Uz>-?\d+\.\d+) (?<co2>-?\d+\.\d+) (?<h2o>-?\d+\.\d+) (?<Ts>-?\d+\.\d+) (?<press>-?\d+\.\d+) (0)\s*|$date,$Xrecord,$XUx,$XUy,$XUz,$Xco2,$Xh2o,$XTs,$Xpress,(0)|);
print EXA1 "$newarray\n";
图片链接不能用,在此补上我写的代码
$XUx =($nowUx+$lastUx)/2;
$XUy =($nowUy+$lastUy)/2;
$XUz =($nowUz+$lastUz)/2;
$Xco2 =($nowco2+$lastco2)/2;
$Xh2o =($nowh2o+$lasth2o)/2;
$XTs =($nowTs+$lastTs)/2;
$Xpress =($nowpress+$lastpress)/2;
while(defined(@rray)){
$newarray = shift @rray;
$newarray =~ (s|(?<date>"\d\d\d\d-\d\d-\d\d\s*\d\d:\d\d:\d\d.?\d?") (?<record>\d+) (?<Ux>-?\d+\.\d+) (?<Uy>-?\d+\.\d+) (?<Uz>-?\d+\.\d+) (?<co2>-?\d+\.\d+) (?<h2o>-?\d+\.\d+) (?<Ts>-?\d+\.\d+) (?<press>-?\d+\.\d+) (0)\s*|$date,$Xrecord,$XUx,$XUy,$XUz,$Xco2,$Xh2o,$XTs,$Xpress,(0)|);
print EXA1 "$newarray\n";
图片链接不能用,在此补上我写的代码
作者: jsftd 发布时间: 2011-05-20
while(defined(@rray))是什么意思?
作者: iambic 发布时间: 2011-05-20