简体   繁体   English

我们可以使用MinGW编译Perl脚本吗?

[英]Can we use MinGW to compile a Perl script?

I have some problems to compile or run a Perl script in Windows. 我在Windows中编译或运行Perl脚本时遇到一些问题。 I have installed MinGW in my Windows to compile C code using the GCC package. 我已在Windows中安装MinGW,以使用GCC软件包编译C代码。 Now, can I use MinGW to compile Perl script/code and how? 现在,我可以使用MinGW编译Perl脚本/代码吗?

No. GCC does not include Perl. 。GCC不包含Perl。 Try Strawberry Perl or ActivePerl for Windows which are Perl distributions for Windows. 尝试Windows的 Strawberry PerlActivePerl(Windows的Perl发行版)。

请参阅PAR :: Packer的前端pp,或“ Cava Packager”,或IndigoStar的Perl2Exe或ActiveState的PerlApp

ActivePerl creates shortcuts for .pl files (if you check the box during installation). ActivePerl为.pl文件创建快捷方式(如果在安装过程中选中该框)。 You can see the association by running the following from a prompt: 您可以通过在提示符下运行以下命令来查看关联:

>assoc .pl
.pl=Perl

>ftype Perl
Perl="C:\Progs\perl5121-ap1201\bin\perl.exe" "%1" %*

(Use wahtever assoc returned as the argument for ftype .) (使用返回的wahtever assoc作为ftype的参数。)

You can do it yourself with: 您可以自己做:

assoc .pl=Perl
ftype Perl=Perl="C:\Progs\perl5121-ap1201\bin\perl.exe" "%1" %*

(Use the correct path for your machine.) (使用正确的机器路径。)

Keep in mind that many scripts require command line inputs, and that the console closes down as soon as the script exits when you launch it from double-clicking. 请记住,许多脚本需要命令行输入,并且从双击启动脚本后,一旦退出脚本,控制台就会关闭。 As such, it's often better to run your script from the prompt. 因此,通常最好从提示符处运行脚本。

If you have the association setup as above, you can run a Perl script from the console simply by typing its name 如果您具有上述关联设置,则只需输入控制台名称即可从控制台运行Perl脚本

>script.pl
Hello, World!

Or you can be explicit and specify that it requires Perl. 或者,您可以明确指定它需要Perl。

>perl script.pl
Hello, World!

That assumes that Perl is in the PATH . 假定Perl在PATH If not, you can specify the whole path to Perl. 如果没有,您可以指定Perl的整个路径。

>C:\Progs\perl5121-ap1201\bin\perl script.pl
Hello, World!

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

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