#! /usr/bin/perl -w # # loadclient.pl # use strict ; use warnings ; use IO::Socket ; my @remote_hosts = ( { addr => '127.0.0.1' }, { addr => '123.123.123.123' } ) ; my $remote_port = 2048 ; foreach my $host ( @remote_hosts ) { my $socket = IO::Socket::INET->new( PeerAddr => $host->{ addr }, PeerPort => $remote_port, Proto => 'tcp', Type => SOCK_STREAM ) or die "Couldn't connect to $host->{ addr }:$remote_port: $@\n" ; $host->{ uptime } = <$socket> ; } # The anonymous hashes in @remote_hosts now also contain # the uptimes of the servers listed.