/try.pl a|b|c|d bash: b: command not found bash: c: command not found bash: d: command not found
That's an error you're getting due to bash, not Perl. You tell bash to call "/try.pl" with the argument 'a', and pipe the result into b, its result into c, and that result into d.

You probably want /try.pl 'a|b|c|d'. But, we aren't done. Once you have 'a|b|c|d', you feed it back into a shell. So, again, you need to escape it, but putting quotes around $_.

But why are you writing a Perl program which all it does it take input, and feed the input back to another shell? Why not just:

#!/usr/bin/sh echo $1 > /tmp/gerbil.txt
However, if you do write it in Perl, why both the backticks, and system? Do you even know what the backticks do? Now you are saying: "Perl, please start a shell, and execute the command I'm giving you. Gather the output, and starts a second shell, executing whatever was written to STDOUT by the first shell." Is that really your intention?

In reply to Re: How to read in data with pipe characters by JavaFan
in thread How to read in data with pipe characters by w3ntp

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.