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

Monks, I'm in the dos shell with ActiveState perl.

oneTwoThree.pl prints

one two three
filterTwoThree.pl checks lines of input and only prints if they match "two" or "three. I want to run something like
filterTwoThree.pl | oneTwoThree.pl
and have this spit out
two three
Is there a way I can hook these scripts up in one line of dos? I have never used pipes before but I am beginning to see how they could be useful. I think this might be easier in the unix shell... is it worth installing Cygwin so I can use pipes?

Thanks for your wisdom!

#!c:/perl/bin/perl #oneTwoThree.pl use warnings; use strict; print "one\n"; print "two\n"; print "three\n";
#filterTwoAndThree.pl use warnings; use strict; if (/two|three/) { print $_; }
UPDATE: Maybe the answer is here: How do I store and manipulate the output from another process?

UPDATE: Thanks RazorbladeBidet. I googled around and found many places that suggested dos pipes were somehow handicapped, but in this case I can get what I want to work with, by adding the -n flag

perl oneTwoThree.pl | perl -n filterTwoAndThree.pl

Replies are listed 'Best First'.
Re: Process output of one script with another script.
by maard (Pilgrim) on Feb 18, 2005 at 18:53 UTC

    So what keeps you from trying if it works or not? just say

    oneTwoThree.pl | filterTwoThree.pl
    instead of
    filterTwoThree.pl | oneTwoThree.pl

    Pipes worked well on DOS from it's earliest versions. But your question isn't related to perl, don't you think? ;)

      Pipes worked well on DOS from it's earliest versions
      although strictly speaking, in early versions of DOS, pipes were just syntactic sugar:
      foo | more is implemented as foo > tmpfile; more < tmpfile; del tmpfile
      which fails utterly in the face of a command that produces infinite output. I don't know whether things have improved since; I certainly hope so, but I haven't used MS on the desktop since 1987.

      Dave.

Re: Process output of one script with another script.
by RazorbladeBidet (Friar) on Feb 18, 2005 at 18:54 UTC
    DOS has pipes, so you won't have any problems. But you have it reversed, you want
    oneTwoThree.pl | filterTwoAndThree.pl

    You basically just want to read the input from STDIN. See perlop for more info
    --------------
    It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs