3

I have a unique problem... I develop Perl on a Windows machine, but my test/prod servers are AIX. I want to be able to test locally with an installation of Apache & Perl, but I don't want to have to change the #! line in all of my scripts to test locally, and then change them back to upload to the test server.

My question is this: can I create some type of shortcut/alias/whatever in Windows in the style of '/usr/bin/perl' that actually points to 'C:\ActiveState\Perl5.0.12\perl.exe' ?

I'm kind of lost on this, so any help at all is greatly appreciated. Thanks!

3 Answers 3

1

Yes, you can. Just create the path as specified in your Perl source code. For example, if you're using #!/usr/pkg/bin/perl then on Windows you can create the path on the same drive (presumably C:) and create a symbolic link to it there (without the .exe).

Depending on what you're doing, it may or may not work, but you'll have to try. If you're expecting to just run your .pl files natively, then this won't work because Windows isn't as flexible as Unix or Linux with regard to reading the first line of a binary to determine how to execute/interpret it.

You can use the Windows "mklink" command to create your symbolic link (thanks to @grawity for suggesting that I add this point).

2
  • 3
    To add - use mklink to create symlinks. Jun 30, 2011 at 20:29
  • 3
    Alternatively, if you're using ModPerl, then on the Windows side this shouldn't matter (and the path in the first line of your Perl scripts can be wrong without causing any problems). The configuration for mod_perl2 that I'm using is described here (complete with configuration file examples): modperl.pl/how-to Jun 30, 2011 at 20:30
1

Don't bother.


C:\> type t1.pl
#!/usr/bin/perl
use strict;
use warnings;
print "that worked\n";

C:\> t1.pl
that worked

But I think Apache needs a correct shebang line - in which case see https://stackoverflow.com/questions/2036577/how-do-i-ignore-the-perl-shebang-on-windows-with-apache-2

0

You can TRY replicating the unix directory structure on your C partition and then you can create sym links accordingly, if on NTFS.. Though on NTFS, they're called "junctions" and Windows Explorer has no means of differentiating junctions from original files/dirs - you need this tool to use NTFS's junction features.

I love sym links and use them like a crazy-guy. But I avoid using junctions on NTFS because explorer doesn't show what they are and I'm afraid of forgetting what I did, or worse, others coming along and causing the world to implode, somehow. Still, that may work for ya. Though it mostly all pends on how the perl interpreter translates unix style paths for use on Windows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .