http://www.perlmonks.org?node_id=11127078

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

Update: Fixed.

Good day fellow Monks,

I'm trying to fix an issue with berrybrew in that when a user wants it to manage Perl's .pl file extension, the user is required to hit ENTER twice to get the output displayed to the screen when running a script from the CLI.

I thought I had the problem resolved on one system, but it exhibits the undesired behaviour on a second one. I'm wondering if a kind monk who's got access to Windows systems can test it out for me.

Repro steps:

Desired outcome: That the words "hello, world!" will be displayed in the console without having to hit ENTER more than once.

When you are said and done testing, and you did in fact have an association set up previously, simply run assoc .pl=whatever_you_wrote_down to revert your system back to original configuration.

I don't know if it's the VM I'm working on is messed up somehow due to development work or not, which is why I'm hoping someone else can test for me. Both of my machines are the exact same version of Win10.

Thanks for any of those who can help me out.

Cheers,

-stevieb

Replies are listed 'Best First'.
Re: File association on Windows
by stevieb (Canon) on Jan 19, 2021 at 08:55 UTC

    The problem wasn't the berrybrew code, nor how I was implementing the changes. Something went awry with my development environment that was causing the issue. I stood up two new separate VMs and can't reproduce the problem, so essentially the undesired behaviour I was trying to fix is definitely fixed.

    I don't know where in the dev VM the problem lies, nor do I really care to spend any further time troubleshooting, so I'm just dumping the VM and configuring a new dev system.

      I was investigating a bit and, no is not fixed :)

      I avoid file type association and I always do: perl myprog.pl in the command prompt. I associate .pl and .pm files with my text editor Notepad++

      I have followed your steps and then in an unpriviledged cmd prompt:

      C>ftype tempPerl tempPerl="C:\EX_D\ulisseDUE\perl5.32.64bit\perl\bin\perl.exe" >assoc .pl .pl=tempPerl >c:\Users\Tizio.Caio\Desktop\hello.pl

      Notepad++ was launched without any effect of the file type association.

      The registry show what is was set previously and explain the actual behaviour:

      C>REG QUERY HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Fi +leExts\.pl HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\OpenWithList HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\OpenWithProgids HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\UserChoice C>REG QUERY HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Fi +leExts\.pl\OpenWithList HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\OpenWithList a REG_SZ {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\OpenWith.exe MRUList REG_SZ ba b REG_SZ notepad++.exe C>REG QUERY HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Fi +leExts\.pl\OpenWithProgids HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\OpenWithProgids pl_auto_file REG_NONE C>REG QUERY HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Fi +leExts\.pl\UserChoice HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\F +ileExts\.pl\UserChoice ProgId REG_SZ Applications\notepad++.exe Hash REG_SZ TXlP+tcVMI0=

      Then I googled and I found:

      The above tests executed on: Microsoft Windows 10 Pro 0.0.19041 N/D build 19041

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        Thanks for the detailed response!

        I, too, always use perl script.pl on all systems, Linux included. In all honesty, I never even use Windows, except to develop berrybrew ironically ;)

        This feature was solely developed because one of my users had asked for it, and since I don't use Windows, didn't notice the problem until another user stumbled across it.

        In your ftype, you're missing a couple of entries. Compare yours:

        tempPerl="C:\EX_D\ulisseDUE\perl5.32.64bit\perl\bin\perl.exe"

        ...to mine:

        C:\repos\berrybrew>ftype berrybrewPerl berrybrewPerl=C:\berrybrew\5.10.1_32\perl\bin\perl.exe %1 %*

        The %1 is the script name, and %* are any arguments passed to it.

        Output (only hitting ENTER once to execute the command):

        C:\repos\berrybrew>t\data\assoc.pl Hello, world! C:\berrybrew\5.10.1_32\perl\bin\perl.exe C:\repos\berrybrew>

        Script:

        use warnings; use strict; print "Hello, world!\n"; print "$^X\n";

        I can't repro the original problem that was reported (having to hit enter twice) on three new systems I've spun up and tried it on, so I'm as content as I can be until it gets wider testing after release and I get actual feedback on it.

        I'll make a note on this thread when I finish the full release with point form notes on how to test it while actually using berrybrew if you or anyone else is interested in testing it in the larger scheme of things.

        As far as registry, I set only HKCR\.pl for the association, and HKCR\berrybrewPerl\shell\open\command for the ftype definition from within the berrybrew library.

Re: File association on Windows
by Anonymous Monk on Jan 18, 2021 at 23:35 UTC

      I've tried both quoting and not quoting, and on the working system, both work equally. On the non-working system, neither quoted or unquoted work.

      Thanks for the links though, but arg passing isn't an issue. It's simply that I have to hit enter twice on one system for the script's output to be displayed, and not on the other.