我想阅读我的套接字并在它们上做一个“ getline”。

my @socket1;
$socket1[0] = IO::Socket::INET->new(
    Type     => SOCK_STREAM,
    PeerAddr => "127.0.0.1",
    Proto    => "tcp",
    PeerPort => $dbase_param{camera_stream}
) or die "Cannot open socket on port " . $dbase_param{camera_stream} . ".\n";

print { $socket1[0] } "\n";
my $ligne = <$socket1[0]>;

while ( !( $ligne =~ /Content-Length:/ ) ) {
    $ligne = <$socket1[0]>;
}


它将告诉我第二个Use of uninitialized value $ligne in pattern match (m//)

我不明白

最佳答案

尖括号也用于glob()

perl -MO=Deparse -e '$ligne = <$socket1[0]>;'
use File::Glob ();
$ligne = glob($socket1[0]);


因此,如果您不使用普通标量作为套接字,则可以使用readline()使其更加明确,

$ligne = readline($socket1[0]);

07-26 03:32