package My::Module; use IO::Socket::INET; ... sub open_socket_to { my ($class, %args) = @_; return IO::Socket::INET->new( PeerAddr => $args{machine}, PeerPort => $args{port}, Proto => $args{protocol} || 'tcp', Type => SOCK_STREAM, ); }