I want to make an array of sockets in perl and add \n, at the end of each socket, I try with &socket[0], but it does not work.
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";
when I do print $socket1[0] "\n";, it will not compile.
but if I do not use an array, it works:
my $socket1;
$socket1 = 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 "\n";
source
share