views:

423

answers:

2

I have Strawberry Perl and have msys Perl 5.6 removed. Now perl will invoke Strawberry (due to PATH env) but how do I map the perl command in .pl or other Perl script file which have #!/bin/perl or #!/usr/bin/perl header? I was think to make a hardlink of perl.exe into msys/bin or merge the whole Strawberry inside msys directory, but I'm not sure

+3  A: 

If you want Strawberry perl to run your scripts by default, use ftype and assoc.

ftype /?
assoc /?

and add the extension you use for Perl scripts to %PATHEXT% (so you can invoke scripts without having to enter the file extension):

ftype perl
perl="C:\opt\Perl\bin\perl.exe" "%1" %*

assoc .pl
.pl=Perl

echo.%PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PL;.PLX;.WPL;.py;.pyw;.PSC1

Of course, for the ftype command specify the path where Strawberry's perl lives.

Sinan Ünür
I'm not sure that would work inside of an MSYS environment. MSYS is a fork of Cygwin.
Brad Gilbert
Well, at this point, MSYS forked off of Cygwin so long ago you might as well call FreeBSD a fork of System V. :)
Robert P
Sinan Ünür, thats not helpfull anf patchy!i need universal solution.. just how you get it right when the file has no extension at all.. ?
twinkletoes
A: 

this works beautifully on the windows side of the computer, on the MSYS side you may need to

  • check the PATH environment variable and fix to include the strawberry perl access path

  • check the scripts for complete path in the shebang line (#!/usr/bin/perl). Those paths that are absolute in msys are in fact relative to the msys install directory in windows. you may need to "plug" your strawberry perl install to match or change the #! line

in the latter case my recommendation would be to use something like: #!env perl that checks the environment for the perl interpreter and alleviate the burden of dealing with /cygdrive/c/my/windows/path/not/visible/from/msys/otherwise