简体   繁体   English

如何在Perl Linux中对文本加下划线?

[英]How do I underline text in Perl Linux?

Is there a way to underline the text is a perl output script? 有没有办法强调文本是perl输出脚本? I have read from several sources but the text in the scripts can't be underlined. 我已经从多个来源阅读过,但是脚本中的文字不能带有下划线。

An error outputs: Global symbol "$finalAddition" requires explicit package name at C:\\Documents and Settings\\PCS\\Desktop\\Perl Scripts\\script.pl line 7. 输出错误:全局符号“ $ finalAddition”在C:\\ Documents and Settings \\ PCS \\ Desktop \\ Perl Scripts \\ script.pl第7行需要显式的软件包名称。

The Script Codes: 脚本代码:

#!/usr/bin/perl

use warnings;
use strict;
use Term::ANSIColor;

$finalAddition = 8;

print "\n\nThe Final Number after addtion would be ".coloured($finalAddition, 'bold 
underline');

Please give some advice on this. 请对此提供一些建议。 Thanks. 谢谢。

This might be to do with variable scoping and having enabled strict mode, rather than what you are trying to achieve. 这可能与变量作用域和启用严格模式有关,而不是您试图实现的目标。 Does changing adding a "my" to the code change anything? 在代码中添加“ my”是否会发生任何变化?

#!/usr/bin/perl

use warnings;
use strict;
use Term::ANSIColor;

my $finalAddition = 8;

print "\n\nThe Final Number after addition would be " .
      colored($finalAddition, 'bold underline');

After rounds of testing and almost smashing the screen, the answer was pretty simple actually... [EDIT] New and better codes! 经过几轮测试并几乎砸碎了屏幕,答案实际上非常简单……[编辑]更好的新代码!

#!/usr/bin/perl

use warnings;
use strict;
use Term::ANSIColor;

my $totalinput = $userinput * $userinput2;

my $coloredText = colored($totalinput, 'bold underline blue');

print "\n\nThe final answer to the question is: $coloredText\n\n";

Thanks for the code advices! 感谢您的代码建议!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM