ley*_*kan 3 sockets arrays perl
我想阅读我的插座并对它们做一个"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]>;
}
Run Code Online (Sandbox Code Playgroud)
它将告诉我Use of uninitialized value $ligne in pattern match (m//)
第二个$ligne = <$socket1[0]>;
我不明白
角括号也用于glob()
,
perl -MO=Deparse -e '$ligne = <$socket1[0]>;'
use File::Glob ();
$ligne = glob($socket1[0]);
Run Code Online (Sandbox Code Playgroud)
所以如果你没有使用普通标量作为套接字,你可能会更明确地使用readline()
,
$ligne = readline($socket1[0]);
Run Code Online (Sandbox Code Playgroud)