+ -
当前位置:首页 → 问答吧 → 关于perl捕获命令输出

关于perl捕获命令输出

时间:2011-03-22

来源:互联网

我通过命令行执行
  1. sed -n 's/.*tests="\([0-9]*\)".*/\1/p' junit_result.xml
复制代码
可以得到结果93。

我写个perl脚本
  1. my $a=`sed -n 's/.*tests="\([0-9]*\)".*/\1/p' junit_result.xml`; print $a;
复制代码
却获取不到结果。

junit_result.xml内容为
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <testsuite name="femtobsr.rtpp.RTPP-regression_full_list" hostname="njbs-231" timestamp="2011-03-21T21:03:38" time="739.917" tests="93" failures="0" errors="0">
  3. <testcase classname="femtobsr.rtpp.RTPP" name="CP Stable clear" time="0.125" />
  4. </testsuite>
复制代码
不知道大家有没有遇到这个问题?

作者: ace_fei   发布时间: 2011-03-22

``像""一样会转义……

作者: 珞水的大叔   发布时间: 2011-03-22

热门下载

更多