我正在尝试查找clearcase视图的最后访问日期,perl脚本如下所示.
@Property = `cleartool lsview -prop $viewtag ` ;
foreach $property (@Property)
{
$last_accessed = $property if ( $property =~ /^Last accessed / );
# | cut -b 15-24 | awk -F '-' '{ print $3"/"$2"/"$1 }'
}
Run Code Online (Sandbox Code Playgroud)
如果cleartool命令失败,我面临的问题是perl脚本退出.即使cleartool返回错误,我希望perl继续.
BRs Mani.
简单而原始的方法是将可能失败的代码放在eval块中:
eval { @Property = `cleartool lsview -prop $viewtag ` };
Run Code Online (Sandbox Code Playgroud)
这样,即使cleartool失败,你的Perl脚本也会继续.
正确的方法是使用像Try :: Tiny这样的适当模块.错误将在变量$ _中的catch块内可用.
try {
@Property = `cleartool lsview -prop $viewtag `;
}
catch {
warn "cleartool command failed with $_";
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
173 次 |
| 最近记录: |