How to run Perl Script from Cmd without typing "perl" before the Script path?

for instance perl C:\Projects\trunk\PcApps\BaseCamp\Test\smoketest.pl C:\Projects\trunk\PcApps\BaseCamp\Test\log.txt

Without perl.

+3
source share
3 answers

Assign the .pl extension to the perl interpreter. It depends on your version of Windows, how you do it.

Depending on the perl installer you use, it may also provide you with the ability to do this automatically.

+6
source

You can put this at the top of your perl script file:

@SETLOCAL ENABLEEXTENSIONS
@c:\strawberry-perl-port\perl\bin\perl.exe -x "%~f0" %*
@exit /b %ERRORLEVEL%

#!perl

....perl program goes here...

script , .cmd .pl. perl , -x, "% ~ f0". .cmd script. .cmd script perl.

#! perl - perl, perl.exe , :

@c:\strawberry-perl-port\perl\bin\perl.exe -x "path\to\my\perl.cmd" %*
+2

, .pl .exe:

perl, , exe perl- . ( : )

0

Source: https://habr.com/ru/post/1773336/


All Articles