I think there is a confusion here between what the first process is doing and what the second process is doing.
I think your intention was that the first process prints the table, and the second process reads it; however both are running the same code, so in the normal course of events the first process sees nothing to read, so does not dump its table; since it outputs nothing, the second process also sees nothing to read, and also does not dump a table.
When you add print "checking pipe\n";, the first process outputs that, sees nothing to read, and exits. The second process now does see something to read - the diagnostic emitted by the first process - so it now calls dumpTable().
The first thing I would suggest to reduce confusion is to use "warn" rather than "print" for your diagnostics, so that they show up on STDERR and not on the pipeline; it may also be useful to show the process id ($$) in those diagnostics, so that you can distinguish the two processes.
I'm not familiar with the debugger, but since it will try to use STDIN to get console input it is certainly likely to confuse the issue.
I tested this with the code below:
% cat t0 #!/usr/bin/perl use strict; use warnings; use IO::Select; $|=1; warn "pid $$ checking pipe\n"; my $s = IO::Select->new(); $s->add(\*STDIN); if ($s->can_read(.5)) { warn "pid $$ can read\n"; print "here is my table\n"; } else { warn "pid $$ cannot read\n"; } % ./t0 | ./t0 pid 24811 checking pipe pid 24810 checking pipe pid 24811 cannot read pid 24810 cannot read % echo "go" | ./t0 | ./t0 pid 26452 checking pipe pid 26452 can read pid 26453 checking pipe pid 26453 can read here is my table %
Update: remove unneeded '(a)'
In reply to Re^2: IO::Select woes
by hv
in thread IO::Select woes
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |