for ($x=3; $x<255; $x+=2){ # make new connection eval { $ssh = Net::SSH::Perl->new("10.0.0.$x", protocol =>2); $ssh->login($user, $pass); }; next if $@; }