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        


In reply to Re^5: Out of date over <> and 5.10 (reproduce) by tye
in thread Out of date over <> and 5.10 by hsmyers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.