开发者

How do I underline text in Perl Linux?

Is there a way to underline the text is a 开发者_如何学编程perl output script? 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.

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?

#!/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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜