用perl调用dos执行perl脚本有什么不同?

Ara*_*ane 1 perl perl-module win32ole ansi-colors

为什么这样的行为呢?

test2color.pl 包含:

#! perl -slw
use strict;
use Win32::Console::ANSI;
use Term::ANSIColor qw(:constants);

print BLACK, ON_WHITE, "black on white\n";
print WHITE, ON_BLACK, "white on black\n";
print GREEN, ON_CYAN, BLINK, "garish!\n";
print RESET;
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

Ekk*_*ner 6

您的

H:\test\perl>perl test2color.pl
Run Code Online (Sandbox Code Playgroud)

使用它在PATH环境变量中找到的第一个perl(.exe).这可能是你的cygwin安装的perl.

H:\test\perl>test2color.pl
Run Code Online (Sandbox Code Playgroud)

使用操作系统信息将扩展名.pl与将运行所有.pl的特定命令行/可执行文件相关联.ftype并且assoc可以用来显示/操作这些关联.

我假设.pl指向的ftype - 完全不同 - c:\Perl\bin\perl.exe.

  • `使用如果$ ^ O eq'MSWin32','Win32 :: Console :: ANSI';`将使它在cygwin以及你的Windows Perl构建下工作. (3认同)