This specific example might be of little use to most, but
it may serve to illustrate the usage.

Taking one program (a character frequency analyzer) and
using it with another program (an LWP::Simple script to
grab a website and show its code), I was able to use a
pipe to count the character frequency of the output of the
html code.

perl lwpprogram.pl | perl characteranalyzer.pl
There are limitless possibilities with this technique.
Two short scripts could do the work of one big one.

Replies are listed 'Best First'.
Re: Using pipes to combine scripts
by artist (Parson) on Nov 17, 2006 at 13:07 UTC
    In Unix world, pipe is used frquently. Here is an example for the web-spell-checker from Wikipedia
    curl "http://en.wikipedia.org/wiki/Pipeline_(Unix)" | \ sed 's/[^a-zA-Z ]/ /g' | \ tr 'A-Z ' 'a-z\n' | \ grep '[a-z]' | \ sort -u | \ comm -23 - /usr/dict/words
    --Artist
      Unix world, pipe is used frquently. Here is an example for the web-spell-checker from Wikipedia

      And while we're there, for the benefit of the OP, we may remind that while on the one hand this is one of the things that can make shell programming very powerful, there are generally better ways to "combine perl scripts" (or better, code) within Perl, where, "better" of course depends on the situation, and is in the eye of the beholder. Just to prevent the system 'this|that|thatother' (a.k.a. shell scripting in Perl) syndrome, you know!

Re: Using pipes to combine scripts
by esk555 (Beadle) on Nov 17, 2006 at 18:18 UTC
    I know that. But it was a nice discovery for me last night,
    therefore I figured it would be a nice discovery for others as
    well.
      I know that. But it was a nice discovery for me last night, therefore I figured it would be a nice discovery for others as well.

      But it is not a cool use for Perl. It's just shell interaction, and of a widely known kind. Look up google for "toolbox philosophy".

        Correction: it wasn't a cool use for you. It was, however, a
        cool use for me, and possibly others who are not experts at Unix.