Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

First, I'm going to assume that you're running on a *nix platform based off of your shebang line.

To call your script, you do have to encapsulate the desired pipe character inside of quotes. If you don't, the shell with believe that the pipe character is telling it to do something. Also, encapsulating it in quotes will not pass the quotes to your script.

For example, let's say you try calling your program like this: perl b c|d|e|f. Here's how your shell will process that.

  1. Need to call the perl executable with parameters
  2. is the first parameter to pass
  3. b is the next parameter to pass
  4. c is the next parameter to pass
  5. Pipe that output to d
  6. Pipe that output to e
  7. Pipe that output to f

In this case, I'd agree with ReturnOfThelonious that the error is from the shell and not your script. If you were instead to call your script like this : perl b "c|d|e|f", here's how your shell would process it.

  1. Need to call the perl executable with parameters
  2. is the first parameter to pass it
  3. b is the next parameter to pass
  4. c|d|e|f is the next parameter to pass

Notice the lack of quotes in the last step? The quotes will basically tell the shell: "Hey, treat everything in side this quote as a parameter and DO NOT view this content as instructions for you to do". The quotes are not actually passed by the shell into your script. This is why toolic suggested that you "quote your passed strings".

I apologize for the length of this post. But since you didn't seem to quite understand what toolic was suggesting, I thought I'd go the extra length to clearly explain the quoting from the shell's perspective.

In reply to Re: Read into stdin pipe characters by dasgar
in thread Read into stdin pipe characters by w3ntp

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (3)
    As of 2018-07-16 01:16 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (330 votes). Check out past polls.