in reply to socket programming error while using it in modular way
You are assigning a list (@_) to a scalar ($socket). Fixing this, cleaning up the indenting, removing the prototypes and connecting to a public service gives:
#!/usr/bin/env perl use strict; use warnings; use IO::Socket; my $s = client_socket_create (); client_main ($s); exit; sub client_socket_create { my $socket = IO::Socket::INET->new ( PeerHost => 'www.perlmonks.org', PeerPort => 80, Proto => 'tcp' ); print "$socket \n"; return $socket; } sub client_main { my ($socket) = @_; print "$socket \n"; }
which prints out the same socket twice as one supposes is intended.
|
|---|