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

Dear Monks,

What happens here:

$ perl | some_command

What gets piped to some_command?

Replies are listed 'Best First'.
Re: What is the output of perl command?
by Anonymous Monk on Jun 16, 2012 at 03:53 UTC
    Nothing, perl waits for input
Re: What is the output of perl command?
by flexvault (Monsignor) on Jun 16, 2012 at 09:36 UTC

    7stud,

    I tried this on an AIX machine and a Debian Linux machine:

    $ perl | ls
    And in both cases I was surprised that the 'ls' executed and I had output, but Perl indeed did wait for input. I then typed a '{ }' and nothing happened. I had to '^C' to break out.

    Interesting...

    "Well done is better than well said." - Benjamin Franklin

      $ perl | ls
      ls does not need input to run. So, it ran and gave the output, perl still waiting for some input.
      Try
      $ perl | wc -l
      and you will see both perl and wc waiting for their respective inputs- perl from the user and wc from the pipe.
      but Perl indeed did wait for input. I then typed a '{ }' and nothing happened. I had to '^C' to break out.
      $PROMPT> perl <press enter key> $name="vaibhav"; print "\nName is $name\n"; __END__ <press enter key> Name is vaibhav $PROMPT>
      :)
      $ echo print(666) | perl -l - | cat 666 $