如何以实时和跨平台的方式将perl代码输出到STDOUT/STDERR和文件? [英] How to get perl code output to STDOUT/STDERR and a file, in realtime and cross-platform?

查看:169
本文介绍了如何以实时和跨平台的方式将perl代码输出到STDOUT/STDERR和文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将常规Perl代码的输出同时输出到屏幕和日志文件中.但是,问题在于该工具的运行时间可能为数小时.使用Capture :: Tiny的tee,这意味着仅在脚本终止后才将日志文件写入日志,这不是很有用.

I need to get the output of normal Perl code to the screen and into a logfile at the same time. However a problem is that the runtime of the tool can be hours. Using Capture::Tiny's tee that means the log file will only be written to once the script terminates, which is not very useful.

为了进一步使事情复杂化,我需要从同一进程以及用system()调用的进程中捕获纯perl的输出.

To further complicate things, i need to capture the output of straight perl from the same process, as well as that of processes called with system().

最后,由于雇主的限制,它也需要在Win32上运行.

Lastly, due to employer restrictions it needs to work on Win32 as well.

我还有其他选择吗?

推荐答案

由于所提供的解决方案都不令人满意,因此我独自坐下并解决了问题:

Since none of the presented solutions were satisfactory i sat down and solved the problem on my own:

捕获:: Tiny :: Extended

这篇关于如何以实时和跨平台的方式将perl代码输出到STDOUT/STDERR和文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆