Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 在命令提示符下从PATH文件夹运行perl脚本_Windows_Perl_Command Prompt_Path Variables - Fatal编程技术网

Windows 在命令提示符下从PATH文件夹运行perl脚本

Windows 在命令提示符下从PATH文件夹运行perl脚本,windows,perl,command-prompt,path-variables,Windows,Perl,Command Prompt,Path Variables,我想运行一个位于PATH目录中的perl脚本。 现在,命令提示符不会在路径目录中搜索参数。它只搜索当前目录中的文件 C:\Users\dg>echo %PATH% ...;C:\Users\dg\abc C:\Users\dg>dir /a-d /b abc abc.pl C:\Users\dg>perl abc.pl Can't open perl script "abc.pl": No such file or directory 如果Perl安装正确,任何解决方案或

我想运行一个位于PATH目录中的perl脚本。 现在,命令提示符不会在路径目录中搜索参数。它只搜索当前目录中的文件

C:\Users\dg>echo %PATH%
...;C:\Users\dg\abc

C:\Users\dg>dir /a-d /b abc
abc.pl

C:\Users\dg>perl abc.pl
Can't open perl script "abc.pl": No such file or directory

如果Perl安装正确,任何解决方案或解决方法都应该适合您。注意,如果您使用
perl abc.pl
,bash也不会搜索
abc.pl
的路径:它将在当前工作目录中查找,如果文件不存在,它将死亡

如果希望Perl搜索脚本文件的路径,请使用
-S
选项

perl -S abc.pl

使用
cd
进入脚本目录。运行以下命令:
路径\u到\u perl\perl.exe abc.pl
看起来像Windows。我使用
controlpanel\Programs\defaultprograms\set Associations
将.pl扩展名设置为由perl打开。然后,命令
abc.pl
只要在路径上就可以正常工作,就像在您的示例中一样。

这个问题的公认答案()应该对您有所帮助