Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^5: strawberry win10 no ARGV

by pryrt (Prior)
on Dec 14, 2019 at 23:54 UTC ( #11110163=note: print w/replies, xml ) Need Help??


in reply to Re^4: strawberry win10 no ARGV
in thread strawberry win10 no 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.

Replies are listed 'Best First'.
Re^6: strawberry win10 no ARGV
by harangzsolt33 (Friar) on Dec 15, 2019 at 03:56 UTC
    Shouldn't Strawberry Perl automatically set this up during installation? I don't understand why people have to do this manually. :/
      Normally, Strawberry does set this up during installation. But sometimes, people just simply copy some files and do it manually, instead of using the setup routine.
Re^6: strawberry win10 no ARGV
by Anonymous Monk on Dec 15, 2019 at 21:58 UTC
    I have near zero recent experience with REGEDIT. I don't find any subkeys. Is there a trick? In ".pl" folder there is one entry: Name= Default Type= REG_SZ Data= pl_auto_file

      First you associate the extension to a type and then the type to executable(s). Look inside the "HKEY_CLASSES_ROOT\pl_auto_file".

      And while you are at it, see whether you have a HKEY_CLASSES_ROOT\Perl key. Maybe just the mapping from the extension to the type was broken, 'cause "ext_auto_file" is something you end up with if you doubleclick an unknown extension and select a program to run it with.

      Jenda
      1984 was supposed to be a warning,
      not a manual!

Re^6: strawberry win10 no ARGV
by Anonymous Monk on Dec 16, 2019 at 16:26 UTC
    I make some changes to regedit which didn't seem to help. However i found when the first argument is the full path to perl.exe everything works! either from the cmd line or using qx inside the wrapper script.
      I make some changes to regedit which didn't seem to help.

      Too bad you didn't show us what changes, otherwise, we could have helped you figure out what you did wrong.

      However i found when the first argument is the full path to perl.exe everything works! either from the cmd line or using qx inside the wrapper script.

      Yes, that's because by supplying the full path to perl.exe first, you are no longer relying on the Windows file association, and are instead directly invoking the perl interpreter yourself. That is a reasonable idiom. However, your double-click won't work.

      If you want double-click to work, you'll need to put in a bit more effort. In this post, you said that .pl maps to pl_auto_file. If you do a reg query HKCR\pl_auto_file /s, you can show us what you actually have set, and we can help you debug. For example, mine (which uses PerlScript, not pl_auto_file), can be seen below

      C:\usr\local\share\PassThru\perl>reg query HKCR\PerlScript /s HKEY_CLASSES_ROOT\PerlScript (Default) REG_EXPAND_SZ Perl Script HKEY_CLASSES_ROOT\PerlScript\shell (Default) REG_EXPAND_SZ run HKEY_CLASSES_ROOT\PerlScript\shell\run (Default) REG_SZ Run Perl Script Icon REG_SZ "c:\usr\local\apps\berrybrew\perls\system\win32\ +strawberry.ico" HKEY_CLASSES_ROOT\PerlScript\shell\run\command (Default) REG_EXPAND_SZ "c:\usr\local\apps\berrybrew\perls\s +ystem\perl\bin\perl.exe" "%1" %*

      update: trimmed extra verbs to avoid confusion

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11110163]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2020-05-28 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (166 votes). Check out past polls.

    Notices?