这是代码:
use Cwd;
use Win32::Console::ANSI;# installed module with ppm
use Term::ANSIColor;
$parent = cwd();
@files = <*>;
print "\n";
foreach (@files)
{
$child = "$parent/$_";
if (-f $_){print "$child\n";}; #file test
if (-d $_)#directory test
{
print color("green")."$child/\n".color("reset");
my($command) = "cd $child/";#submerge one directory down ( recursive here?)
$command=~s/\//\\/g;
system( $command );
};
}
我遇到的问题是输出着色的方式。我期望得到的是黑色背景上的绿色“某个目录”。相反,我得到绿色的背景颜色和黑色的文本,有时是随机的白色。我在使用 color() 的所有其他代码上都有这个问题。我注意到重新启动后问题消失了。另外,我怀疑当我运行其他一些 perl 代码时,问题会再次影响 DOS 及其所有窗口。基本上,一旦出现问题,它就会一直存在,直到重新启动 color() 的每个实例。它看起来像一个小故障。请帮忙。