for ($i=1;$i<10;$i++) { my ${sock$i} = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => '389', Proto => 'tcp', ); die "Could not create socket: $!\n" unless ${sock$i}; }