Okay, I think I understand what you are doing. To rephrase a bit, your perl program reads standard input and echoes to standard output. When standard input is a terminal/console, the program works as expected, but when the standard input is redirected from the output of netcat, it fails to wait for input.
My version of netcat was built without the '-e' option, so I cannot test directly with it. I tried using the bash commandline to redirect the standard output of netcat into your program, and as expected, this worked. The difference is that in your instance, netcat is the parent of your perl program. I am hypothesizing that this is causing your program to read its standard input before the parent process has been able to receive from the network, and this is causing the read from stdin to return undefined. To test this hypothesis, try this:
Code:
#! /usr/bin/perl -w
use strict;
my $sLine = "";
while( ! defined ( $inp ) ){
$sLine = <>;
}
print "Received: $sLine\n";
Let us know how that changes things.
--- rod.