如何在Windows上从Perl脚本为输出文本着色? [英] How do I color output text from Perl script on Windows?

查看:94
本文介绍了如何在Windows上从Perl脚本为输出文本着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Perl打印命令对打印到控制台的文本进行彩色格式化。

I would like to color format the text printed to the console using the Perl print command.

在我的情况下,脚本只能在WinXP-DOS命令下运行行,但是如果它与操作系统无关,那将是很棒的,尽管我宁愿将它绑定到WinXP而不是必须下载单独的软件包。

In my case the script will only be run under WinXP-DOS Command Line but it would be great if it was OS independent although I would rather tie it to WinXP than have to download a seperate package.

推荐答案

对于任何支持 ANSI转义码的终端,您可以使用 Term :: ANSIColor程序包在CPAN上可用。

For any terminal that supports ANSI escape codes you can use the Term::ANSIColor package available on CPAN.

从Wikipedia页面:

From the Wikipedia page:


基于NT的Windows版本
中的控制台窗口(Windows NT 4.0,Windows
2000,Windows XP,Windows Server 2003,
Windows Vista和Windows Server 2008)
本身不支持ANSI Escape
序列,尽管可能有
的支持。

Console windows in Windows versions based on NT (Windows NT 4.0, Windows 2000, Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008) do not natively support ANSI Escape sequences, though some support is possible.

我不知道Windows特定的信息,我是POSIX专家。 :-)

Don't know any more Windows-specific information than that, I'm a POSIX guy. :-)

这篇关于如何在Windows上从Perl脚本为输出文本着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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