Creating a bunch of variables like $t1, $t2, $t3 and so on for each connection would be a bad idea, as perl already has data structures available for storing lists of data like this, which are much easier to use. You could either store them in an array like so:
Or you could store them in a hash with the target IP addresses as the keys:$t = Net::Telnet->new(...); $t->open(...); push @array, $t;
You are also *not* iterating over all of the addresses you want to. The range you say you want to work through runs from FOO.BAR.0.0 to FOO.BAR.255.255. You ignore a whole bunch of them. I'm not going to pick over your convoluted method for generating the list to figure out exactly what you skip over, but here's how I'd do it:$hash{"$ip.$ip3.$ip4"} = $t
my $base = (192 << 24) + (168 << 16); foreach my $ip ($base .. $base+65535) { $t = Net::Telnet ... $t->open(... $hash{$ip} = $t; }
In reply to Re: how to fork/spawn 64k telnet connections and keep them all open
by DrHyde
in thread how to fork/spawn 64k telnet connections and keep them all open
by ike_ipsec_dude
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |