Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Out of date over <> and 5.10 (redir)

by BrowserUk (Patriarch)
on Sep 08, 2010 at 14:48 UTC ( [id://859338]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Out of date over <> and 5.10 (redir)
in thread Out of date over <> and 5.10

I suspect you messed up your test.

Sorry, the absence of error message was simply because I also had a 'junk.bat' in the same directory that did nothing silently. But it doesn't invalidate the premise.

Having deleted that, here is a full re-test in a completely virgin session, that I believe confirms the source of this old 'mystery bug':

Microsoft Windows [Version 6.0.6001] Copyright (c) 2006 Microsoft Corporation. All rights reserved. c:\>cd test c:\test>set pathext PATHEXT=.pl;.COM;.EXE;.BAT;.CMD; c:\test>junk junk.pl 'print "'$_'" while <>; ' c:\test>junk < junk.pl 'print "'$_'" while <>; ' c:\test>type junk.pl | junk 'print "'$_'" while <>; ' c:\test>set pathext=.com;.exe;.bat;.cmd; c:\test>set pathext PATHEXT=.com;.exe;.bat;.cmd; c:\test>junk junk.pl 'junk' is not recognized as an internal or external command, operable program or batch file. c:\test>junk < junk.pl 'junk' is not recognized as an internal or external command, operable program or batch file. c:\test>type junk.pl | junk 'junk' is not recognized as an internal or external command, operable program or batch file. c:\test>set pathexe=%pathext%.pl; c:\test>set pathext PATHEXT=.com;.exe;.bat;.cmd; c:\test>set pathext=%pathext%.pl; c:\test>set pathext PATHEXT=.com;.exe;.bat;.cmd;.pl; c:\test>junk junk.pl 'print "'$_'" while <>; ' c:\test>junk < junk.pl 'print "'$_'" while <>; ' c:\test>type junk.pl | junk 'print "'$_'" while <>; ' c:\test>

Replies are listed 'Best First'.
Re^5: Out of date over <> and 5.10 (reproduce)
by tye (Sage) on Sep 08, 2010 at 17:42 UTC

    I tried to come up with a complete test case that anybody could run, since this behavior seems to vary based on tiny things, perhaps down to unknown quirks in different environments. Perhaps this test case can be extended to cover the quirks that get discovered to the point that it demonstrates failure and success of piping / redirection in exactly the same cases on lots of different systems.

    echo on assoc .pl=perltest perl -e"system(qq(ftype perltest=$^X \"%%1\" %%*))" ftype perltest mkdir pipe cd pipe pipe perl -e "print 'print qq(| $_) while <>'" > pipe.pl set pathext=.pl;.com;.exe;.bat;.cmd; pipe pipe.pl pipe < pipe.pl type pipe.pl | pipe set pathext=.com;.exe;.bat;.cmd; pipe pipe.pl pipe < pipe.pl set pathext=.com;.exe;.bat;.cmd;.pl; pipe pipe.pl pipe < pipe.pl type pipe.pl | pipe del pipe.pl cd .. rmdir pipe

    Running it myself gave me different results than BrowserUk's. First, the boring pre-amble:

    C:\> echo on C:\> assoc .pl=perltest .pl=perltest C:\> perl -e"system(qq(ftype perltest=$^X \"%1\" %*))" perltest=C:\strawberry\perl\bin\perl.exe "%1" %* C:\> ftype perltest perltest=C:\strawberry\perl\bin\perl.exe "%1" %* C:\> mkdir pipe C:\> cd pipe C:\pipe> pipe 'pipe' is not recognized as an internal or external command, operable program or batch file.

    That last line shows that I don't have an old pipe.exe or pipe.bat hanging around to confuse things.

    C:\pipe> perl -e "print 'print qq(| $_) while <>'" 1>pipe.pl C:\pipe> set pathext=.pl;.com;.exe;.bat;.cmd; C:\pipe> pipe pipe.pl | print qq(| $_) while <> C:\pipe> pipe 0<pipe.pl C:\pipe> type pipe.pl | pipe

    The above shows that neither piping nor redirection works for me when I leave off .pl even when .pl is first in PATHEXT (the case where it worked for BrowserUk).

    C:\pipe> set pathext=.com;.exe;.bat;.cmd; C:\pipe> pipe pipe.pl 'pipe' is not recognized as an internal or external command, operable program or batch file. C:\pipe> pipe 0<pipe.pl 'pipe' is not recognized as an internal or external command, operable program or batch file.

    The above is the boring middle part.

    C:\pipe> set pathext=.com;.exe;.bat;.cmd;.pl; C:\pipe> pipe pipe.pl | print qq(| $_) while <> C:\pipe> pipe 0<pipe.pl C:\pipe> type pipe.pl | pipe

    The above shows that redirection and piping also fails for me when .pl at the last item in PATHEXT (the case where it also failed for BrowserUk (update:) based on my prior reading of his node but that doesn't appear to have failed for him in my latest reading of his node).

    C:\pipe> del pipe.pl C:\pipe> cd .. C:\> rmdir pipe C:\>

    That last chunk is the boring end.

    In the process of trying to get ftype / assoc to actually work, I found a lot of quirks that are possible in the Classes/.pl and Classes/testperl Registry keys. I suspect that there is something here that is important. To be clear, when I ran this test case, I had previously deleted the Class/.pl and Class/perltest Registry keys. I didn't include those steps in the test case as I figured some might find such a drastic step impolite and also because I suspect such a step would mask some of the existing quirks that cause different behavior for different people.

    Somebody should probably add code to the test case that saves the keys, deletes them, and then restores them at the end. Unfortunately, the Windows Registry doesn't appear to support "rename key".

    - tye        

      Here's what I get. Everything works. (At least how I would expect it to.)

      c:\test>pipetest c:\test>echo on c:\test>assoc .pl=perltest .pl=perltest c:\test>perl -e"system(qq(ftype perltest=$^X \"%1\" %*))" perltest=C:\Perl64\bin\perl.exe "%1" %* c:\test>ftype perltest perltest=C:\Perl64\bin\perl.exe "%1" %* c:\test>mkdir pipe c:\test>cd pipe c:\test\pipe>pipe 'pipe' is not recognized as an internal or external command, operable program or batch file. c:\test\pipe>perl -e "print 'print qq(| $_) while <>'" 1>pipe.pl c:\test\pipe>set pathext=.pl;.com;.exe;.bat;.cmd; c:\test\pipe>pipe pipe.pl | print qq(| $_) while <> c:\test\pipe>pipe 0<pipe.pl | print qq(| $_) while <> c:\test\pipe>type pipe.pl | pipe | print qq(| $_) while <> c:\test\pipe>set pathext=.com;.exe;.bat;.cmd; c:\test\pipe>pipe pipe.pl 'pipe' is not recognized as an internal or external command, operable program or batch file. c:\test\pipe>pipe 0<pipe.pl 'pipe' is not recognized as an internal or external command, operable program or batch file. c:\test\pipe>set pathext=.com;.exe;.bat;.cmd;.pl; c:\test\pipe>pipe pipe.pl | print qq(| $_) while <> c:\test\pipe>pipe 0<pipe.pl | print qq(| $_) while <> c:\test\pipe>type pipe.pl | pipe | print qq(| $_) while <> c:\test\pipe>del pipe.pl c:\test\pipe>cd .. c:\test>rmdir pipe

        Thank you! Would you consider saving off then deleting your Classes/.pl registry key and trying the test case again? (Any other attempts to find quirks that impact this problem also appreciated.)

        - tye        

Re^5: Out of date over <> and 5.10 (redir)
by ikegami (Patriarch) on Sep 08, 2010 at 16:17 UTC

    I believe confirms the source of this old 'mystery bug'

    No. If anything, you disproved it. All your tests show the correct output. None acted as if they were passed an empty or closed handle for STDIN.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found