这就是代码:
print color("red"), "INPUT>"; color("reset"); chomp($ip = <STDIN>);
在cmd中,一切都很好,直到这一行。错误是:在script2.pl第7行调用未定义的子例程&amp; main :: color。
答案 0 :(得分:6)
使用Term::ANSIColor
模块。
use Term::ANSIColor;
print color('bold blue');
print "This text is bold blue.\n";
print color('reset');
print "This text is normal.\n";
print colored("Yellow on magenta.", 'yellow on_magenta'), "\n";
print "This text is normal.\n";
print colored(['yellow on_magenta'], 'Yellow on magenta.', "\n");
print colored(['red on_bright_yellow'], 'Red on bright yellow.', "\n");
print colored(['bright_red on_black'], 'Bright red on black.', "\n");
print "\n";