# Perl 5.32 Perl script run as command found in path receives no arguments

I installed a configured Perl 5.32.1 project on a WIN 10 system using the ‘state deploy’ command. I found that I could not run a script in the path, like x.pl, by simply typing x in a command window. I added .PL to PATHEXT. I then realized that .pl was not associated with any program, so I associated it with the perl.exe in the installation directory. Now a script can be found in the path and run, but there are no command line arguments passed to the script ARGV is empty. If I run perl x.pl arg1 arg2, it works fine.

Is it intended that current versions of Perl can run scripts in the path as the older versions before the state tool could? Should this be set up by the deploy command? Has anyone seen and solved this problem?

Other than this, I found that I can easily configure a Perl project, select needed packages using the state command, and deploy. This solves the loss of ppm plus opens up most of CPAN to Windows systems.

Thanks,

Stewart

Hey @stewartbholt,

Thanks for writing! This is a new issue as far as I know and the documentation doesn’t make an explicit statement on the matter. I’ll ask the dev team for input here.

Also, I was really quite glad to read this:

Other than this, I found that I can easily configure a Perl project, select needed packages using the state command, and deploy. This solves the loss of ppm plus opens up most of CPAN to Windows systems.

… thanks for letting us know!

Cheers!
–zak

After hearing that this is an unknown problem, I started digging. I wrote a script which reads from and and passed it arguments, While it was waiting on input, I used the Task Manager to look at its command line and as I expected the arguments were absent. I searched the registry for “bin\perl.exe” as a value. I found several places, but the following seemed most likely to be involved. This key was likely created when I associated Perl with the .pl extension.
HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command
I added 3 characters to the end of the existing value, ’ %’ resulting in:
“C:\AS\Perl-5.32.1\bin\perl.exe” “%1” %

Now arguments are passed to the script.

The steps I used were:

1. Dig through the dumbed down MS interface settings to be able to browse to a program to associate with an extension. Set perl.exe for .pl.
2. Add .pl to the PATHEXT environment variable.
3. Change the registry entry as noted above.

The above key does not even exist on another system where perl 5.26 was installed by the
AS installer, so there must be more than one way to accomplish this on Windows. With these changes, simply typing the name of a Perl script located in a directory on your PATH will execute it with the arguments passed.

I would still like to hear from AS developers as to whether there will be changes to support using Perl scripts as commands.

Thanks,

Stewart

Hi Stewart, thanks for taking the time to dig into this! There is an alternative way to ensure your arguments get passed, using a command prompt with administrator privilege:

FTYPE Perl=C:\Path\to\perl “%1” %*
ASSOC .pl=Perl

We’ll be looking into performing these actions automatically for perl runtimes installed with state deploy in the near future.

Shaun.

1 Like

While I have nothing to add with regards to Perl script execution (beyond what Shaun already said) I do want to point out that state deploy is largely intended for “install and forget” type of situations. If you intend to actively work on your project (ie. installing / updating packages) you would ideally be using state activate.

Thanks. I set up my project on the web and deployed it on a laptop to have it is a backup place to run an application which processes data once an hour. This also serves as a test of the state tool perl. Your reply brings up some questions: Can I update this deployed perl from the web resident project, if I add modules to it? If not, how to uninstall so that I can reinstall?

My main system has 5.26 and was configured via ppm. I plan to switch to an activated 5.32.1 on the desktop as soon as I determine that everything is working on the laptop and I am close to that now. For the cleanest environment, do I need to or should I uninstall 5.26 first?

The state tool documentation is good for documenting the commands and options, but additional documentation would be helpful to make it easy for old PPM users to know the steps to set up a development environment and a production environment. A discussion of how to to update the environments and the differences between activate and deploy and when you would best use each. I had originally done an activate and I think I hit the problem this post described and switched to deploy in hopes it would make the associations. In addition to managing perl projects on my desktop, adding packages and further development of applications, I want to be able to execute perl scripts as commands in any command prompt. Can I have a project deployed for general use and other project(s) activated for adding CPAN packages and incorporating them into applications on the same system? Then at a point, I would want this branch of the project to be deployed. A discussion of this would make switching from perl with ppm to the state tool much easier.

Thanks

Stewart

1 Like

Thanks for the additional information, @stewartbholt! We’ll put this info together for you.

Cheers!
–zak

Thank you. That will be very helpful. I will give feedback and maybe it can evolve into an easy to follow procedure to get someone started.

Stewart