in reply to ARGV Problem

On the command line (cmd.exe) check:

>assoc .pl .pl=Perl >ftype Perl Perl="E:\Perl\bin\perl.exe" "%1" %*

This (path to perl.exe according to your machine) would assure you, that your Perl is properly installed.

You should be able to call perl scripts just by name.

You can can even go further and:

>set pathext PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH >set PATHEXT=%PATHEXT%;.PL

With that you are able to call you perl script just by name, even without the .pl extension (provided no other file with same basename and other executable extension is found before your script is concidered).

You can make the environment change permanent by editing PATHEXT in start>settings>system>advanced>environment

Under these circumstances

>echo print "@ARGV" >targ.pl >targ 1 2 3 1 2 3 >perl -e "system 'targ', 1, 2" 1 2

But, I've seen that misbehaviour (script name triggers execution, but @ARGV is not available) reported a few times in the past (for W2K and XP). Heck, I even had once such a machine (NT4) years ago at work, but did not know enough then about perl and Windows command execution to solve the mystery.

In all these cases a call of perl with the script (and its parameters) as argument was processed correctly.

I will sleep better, once someone is able to explain what causes this (and I can read it somewhere posted) ;-)


And Celada++ for the post right on spot wrt Shebang parsing.

Replies are listed 'Best First'.
Re^2: ARGV Problem (pl2bat++)
by tye (Sage) on Jan 07, 2006 at 02:58 UTC

    I use pl2bat (included in Win32-perl's 'bin' directory) and so don't have to worry about this. But it is more because you shouldn't have to know what language tool X is written in just to use X. So I never run perl scripts via "script.pl ..." nor via "perl script...".

    I've rewritten tools between Perl, *.cmd, C++, etc. and don't need to retrain my fingers much less have to find and update other tools that happen to use the rewritten tool.

    - tye        

      ...nor via "perl script...".

      Well, you do... your pl2bat generated batch files do it for you...

      I see your point, but as someone who long abandonded maintaining dual language scripts (since my change from using Perl5 instead of Perl4 and using WinNT, which gave me a way to just declare .pl files "executable") and someone who is supposed to support Win at work, I prefer not to ignore this "1 in a million" problem, but seek for a proper explanation/fix.