use IO::Socket; my $sock1 = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => '80', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock1; my $sock2 = new IO::Socket::INET ( PeerAddr => '127.0.0.1', PeerPort => '80', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock2; #### 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}; }