The Command prompt (cmd.exe) will pipe information from one 'process' to a 'thing' where the target is either an executable (.exe, .com) or a batch file (.bat, .cmd). The key is that the target must be supported directly by CMD.exe without external help.

The command prompt will also 'do something' with any filename that you type in and press enter. The action carried out is the default action determined by the registry entries for the particular file extension. Normally this application is something that lets you view or edit the file. e.g. enter index.htm and IE loads the file.

In the example above, the current directory contains a file called myscript.pl. If you enter myscript.pl at the command prompt, the .pl extension is associated with Perl.exe and so the file will be sent to Perl.exe with myscript.pl as the first argument. Since the file happens to contain some instructions that Perl.exe can understand, Perl.exe carries out the instructions.

This behavior kind of makes Perl scripts look like programs in their own right since the default action sends them to Perl.exe and they do something. Perl.exe does it's own thing in the background and we kind of forget that it is running.

myscript.pl is however still just a file and not an executable. When you try and pipe the output from another program into the myscript.pl file then you don't get very far since you pipe into processes not files. If on the other hand you use the explicit Perl or PL2BAT route then you are piping into a process that has myscript.pl as it's first argument.


In reply to Re: pipe to script requires '| perl' on win32 by inman
in thread pipe to script requires '| perl' on win32 by QM

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.