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

Hi Monks!

Using activestate perl on Win2000, I was able to pass command line parameters to my program without prefacing the perl script with the word perl.

e.g. foo.pl 2 3

Now on XP (and a more recent, i.e. the latest version of activestate perl), the command line parameters aren't passed unless I preface the word perl in front...

e.g. perl c:\myprograms\foo.pl 2 3

I'm not sure if this has to do with winXP or the activestate perl version.

Is there a setting I can change to enable command line processing without having to include the word perl before the script name?

  • Comment on Problems passing command line parameters to activestate perl on XP

Replies are listed 'Best First'.
Re: Problems passing command line parameters to activestate perl on XP
by Corion (Patriarch) on Jan 13, 2007 at 15:24 UTC
Re: Problems passing command line parameters to activestate perl on XP
by BrowserUk (Patriarch) on Jan 13, 2007 at 15:50 UTC

    Check the associations. Specifically, check the command line associated with the extension. They should look (something) like this:

    Updated: Removed the switches: -sw which are are my preference but controversial.

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

    If they do not, change them to suit your installation.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Ok I got it working, but not sure what exactly fixed it
      One thing I did was the following :

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

      But even that didnt work until I went into explorer file associates, selected PL file, and clicked "restore"

      Thanks for the tips!

      ftype returns the same string as yours except that the -sw is missing. How do I update that association?

      Thanks!

        The -sw is unnecessary, just my preference. I've updated the post to reflect that.

        The other possibility for it not working is that your environment variable PATHEXT is not set correctly. What do you get if you type set PATHEXT at the command line?

        It should look something like this:

        c:\test>set PATHEXT PATHEXT=.COM;.EXE;.BAT;.CMD;.pl;

        It may well have some extra entries for other languages, but the salient part is the presence of the .pl;. Without that, .pl files will not be recognised as executable files.

        To modify this permenantly, you need to set it into the global environment. This is done through the System Properties dialog (righ-click the My Computer icon on the desktop). On the Advanced tab you'll see a button labelled "Environment variables". Clicking that brings up a dialog split into two parts: 'User variables' and 'System variables'. If you scroll the 'System variables' list down until you can highlight the PATHEXT variable and then click the 'Edit' button underneath, you will then be able to add the .pl; entry.

        After that, click 'Ok' 3 times and you start a new command line window and try the commands again. It should now work.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Problems passing command line parameters to activestate perl on XP
by ww (Archbishop) on Jan 13, 2007 at 15:35 UTC
    Not sitting at an XP box, but an XP user may be able to augment this.

    This sounds like an XP association's issue, which, if diddling the registry sounds like more of a challenge than you wish to confront, you may be able to deal with this way:

    In the file manager, there's an Option for File associations. There (sorry, I may have missed one level here) you should be able to edit the associations... and you'll have to be careful to create a new run or open association with your AS Perl installation.

    Be careful. Depending on how you work, you may have (or, "need") an association for edit.