Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've always noticed this little glitch on win32 and was wondering if there is a way to fix it. Namely, calling a script as 'perl foo.pl arg1 arg2' gives @ARGV = qw(arg1 arg2);, while 'foo.pl arg1 arg2' gives an empty @ARGV. What gives? And is there a way to fix this behaviour? Are the arguments passed in anywhere else (I've checked in @_, no luck).

Replies are listed 'Best First'.
Re: Win32 - @ARGV with 'perl foo.pl' vs 'foo.pl'
by halley (Prior) on Apr 01, 2004 at 18:36 UTC
    Sounds like your windows registry entry for filename association is broken. (That's what turns "foo.pl" into a request to run a command like perl.exe and what arguments should be included.)

    --
    [ e d @ h a l l e y . c c ]

      They recommend:

      ASSOC .pl=PerlScript FTYPE PerlScript=perl.exe %1 %*

      Looks fine to me (I think):

      C:\>assoc .pl .pl=pl_auto_file C:\>ftype pl_auto_file pl_auto_file="c:\perl\bin\perl.exe" "%1"

        That pl_auto_file doesn't include any further arguments, so that's why they're disappearing. I'm not at a machine where I can show you what it should be, but...

        pl_auto_file="c:\...\perl.exe" "%1" %2 %3 %4 %5 %6 %7 %8 %9
        or
        pl_auto_file="c:\...\perl.exe" "%1" %2*
        Or something like that.

        --
        [ e d @ h a l l e y . c c ]

Re: Win32 - @ARGV with 'perl foo.pl' vs 'foo.pl'
by Anonymous Monk on Apr 01, 2004 at 18:52 UTC

    Aha. The fix for me was to open up the registry and change the value of the 'Default' value at "HKEY_CLASSES_ROOT\pl_auto_file\shell\open\command\" from "c:\perl\bin\perl.exe" "%1" to "c:\perl\bin\perl.exe" "%1" %*