in reply to Re: strawberry win10 no ARGV
in thread strawberry win10 no ARGV

I am mostly interested in calling from another script. I've tried qx, backticks, and system. So Eventually I tried simply from the command line, like. "scriptname.pl 09 12 34likj" No dice. My code is basically
my $i = 0 ; for ( @ARGV ) { $i++ ; print "i:$i for argv $_\n" ; } print "$i is the final index of argv\n" ;
All my scripts work fine in win7 + activeperl

Replies are listed 'Best First'.
Re^3: strawberry win10 no ARGV
by pryrt (Abbot) on Dec 14, 2019 at 22:46 UTC

    your file association is wrong. You need %* after the "%1" in the command your association runs.

      I guess you're joking? Anyhow why can't I call one script from another script and send it @ARGV ?
        I guess you're joking?

        Nope.

        Anyhow why can't I call one script from another script and send it @ARGV ?

        Because your association is wrong; to quote myself, when I wasn't joking, "You need %* after the "%1" in the command your association runs".

        Since that wasn't enough information for you, here are more details: A .pl is not an executable file from Window's perspective. It has to be associated with an application (perl.exe, in this case), otherwise Windows cannot do anything with it. If you didn't have an association, you wouldn't get the script to run at all by just calling scriptname.pl, with or without arguments after it. Since it runs, but just doesn't pass arguments, I can nearly guarantee that there is an association, but that it is only passing the .pl filename to the script (with "%1"), and not any additional arguments you pass (with %*). If you want Windows to pass the command line arguments, "You need %* after the "%1" in the command your association runs". The symptoms you describe indicate that your association doesn't have the %* it needs.

        Run regedit, then navigate to HKEY_CLASSES_ROOT\.pl. The default value will say something like auto_pl_file or PerlScript, or something like that. Navigate to HKEY_CLASSES_ROOT\auto_pl_file or whatever it was called; there will be a subkey called shell, with a subkey something like run, with a subkey called command. The default value for the command will be similar to c:\strawberry\perl\bin\perl.exe "%1", where the path to perl.exe will be wherever your copy of strawberry perl is; you need to change it c:\strawberry\perl\bin\perl "%1" %*, with the %* included. If the %1 is not in quotes, put it in quotes, otherwise any script that has a filename or path element that has a space will not work either.