I want to do an array of socket in perl and add a \n, at the end of each socket, I try with &socket[0] but it doesn't 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 the print $socket1[0] "\n"; it will not compile.
but if I don't 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";
                print's filehandle needs to be a glob or a simple scalar (possibly the result of a BLOCK).  This should work:
print { $socket1[1] } "\n";
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With