Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Perl Cascading Calls, Losing STDIN?

by bbfu (Curate)
on Jun 14, 2004 at 18:42 UTC ( #366659=note: print w/replies, xml ) Need Help??

in reply to Perl Cascading Calls, Losing STDIN?

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

Black flowers blossom
Fearless on my breath

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://366659]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-06-28 23:30 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (652 votes). Check out past polls.