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

Hello. I am using Windows 7, ActiveState Perl, # 5.24.1 MSWin32-x64-multi-thread.

It seems my code snippet test.pl will not work unless I use "perl" on the command line. There were no problems before I upgraded to 5.24.1 a few hours ago. Are my eyes just not seeing something? I get the same sort of results if I use Getopt::Long instead of ARGV

# C:\temp>test.pl --drive E # My argv's are and # drive is # C:\temp>perl test.pl --drive E # My argv's are --drive and E # drive is E use 5.18.2; say ("\tMy argv's are $ARGV[0] and $ARGV[1]");

Replies are listed 'Best First'.
Re: ARGV not getting set
by ikegami (Patriarch) on Aug 04, 2017 at 03:36 UTC

    You have a poorly constructed file association (e.g. one created by double-clicking an un-associated .pl file). Recreate it as by running the following two commands:

    ftype perlfile="D:\Perl\bin\perl.exe" "%1" %* assoc .pl=perlfile

    Adjust the path as needed.

      The solution proposed by ikegami is probably correct. However, I recommend against using these commands until you have read and understood their documentation.
      help ftype help assoc
      Bill
Re: ARGV not getting set
by Anonymous Monk on Aug 04, 2017 at 01:29 UTC

    Hi,

    Use the Start Button to find Default Prograns to see what program file type .pl is associated with and, if necessary, associate it with your perl executable.

    J.C.

      My thanks to those who are suggesting Windows 7 is not knowing which program to associate with a .pl file. However, from the shown results we can surmise that the system finds C:\Perl\bin\Perl.exe on it's own and executes the short .pl script. It therefore knows the correct association. It just does not set ARGV correctly. Just as a check, I looked at the Default Programs as suggested and it does indeed say .pl is set to the "Perl Command Line Interpreter".

      Hmmm. Activestate wanted to install Perl into C:\Perl64. I told it to install it to C:\Perl instead. Maybe that is the problem. I will try to move C:\Perl elsewhere and reinstall the latest Perl to C:\Perl64.

      Time passes ...

      Okay, I just uninstalled and then reinstalled Perl. The problem went away. Thank goodness.

Re: ARGV not getting set
by karlgoethebier (Abbot) on Aug 04, 2017 at 08:03 UTC

    Déjà-vu, less or more...? Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Re: ARGV not getting set
by mnooning (Beadle) on Aug 04, 2017 at 00:22 UTC
    The real results are below.
    # C:\temp>test.pl a b # My argv's are and # C:\temp>perl test.pl a b # My argv's are a and b