Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'm not entirely sure I know what you're asking. I've included some test code and output below to hopefully clarify.

[johnsca@cory johnsca]# cat tst.pl #!/usr/bin/perl my $run = $ARGV[0] + 1; chomp(my $val = <STDIN>); print "Test #$run: '$val'\n"; system('./tst.pl', $run) unless $run >= 3; [johnsca@cory johnsca]# ./tst.pl foo Test #1: 'foo' bar Test #2: 'bar' baz Test #3: 'baz' [johnsca@cory johnsca]# cat tst.inp foo bar baz quux [johnsca@cory johnsca]# ./tst.pl < tst.inp Test #1: 'foo' Test #2: '' Test #3: '' [johnsca@cory johnsca]# cat tst.inp | ./tst.pl Test #1: 'foo' Test #2: '' Test #3: ''

Basically, the issue I'm seeing is that the subprocesses read from STDIN normally as long as it was not redirected or piped in any way. This seems strange, and I don't really have any idea why it would be handled any differently. I don't know if it's a perl issue, a shell issue, or an OS issue.

I get the same behavior on the following perls:

  • v5.8.2 built for cygwin-thread-multi-64int
  • v5.8.4 built for i686-linux

I tried it under bash on both systems, and ash on linux.

Anyway, sorry I can't really give any answers but hopefully this will prompt someone a little more knowledgeable in this area than myself to chip in.

P.S. In the future, it is best to include code samples (the minimum required to duplicate the behavior) to demonstrate exactly what your problem is.

bbfu
Black flowers blossom
Fearless on my breath


In reply to Re: Perl Cascading Calls, Losing STDIN? by bbfu
in thread Perl Cascading Calls, Losing STDIN? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found