Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question

3 Answers 3

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).

share|improve this answer
3  
To add - use mklink to create symlinks. –  grawity Jun 30 '11 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 –  Randolf Richardson Jun 30 '11 at 20:30

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 http://stackoverflow.com/questions/2036577/how-do-i-ignore-the-perl-shebang-on-windows-with-apache-2

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.