gpt4 book ai didi

arrays - 在 perl 中使用 <$socket[i]> 读取数组中的套接字

转载 作者:行者123 更新时间:2023-12-02 03:24:05 24 4
gpt4 key购买 nike

我想读取我的套接字并对它们执行“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//)第二个$ligne = <$socket1[0]>;

我不明白wy

最佳答案

尖括号也用于 glob(),

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

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

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

关于arrays - 在 perl 中使用 <$socket[i]> 读取数组中的套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26276400/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com