title: Perl: How to get IO::Socket::INET timeout after X seconds?
body: <p>I'm trying to connect to some host, using invalid port, and i want to get timeout after X seconds. How to do that ?</p>
  
  <p>My code:</p>
  
  <pre><code> $sock = new IO::Socket::INET(
                    PeerAddr =&gt; $_[0],
      PeerPort =&gt; $_[1],
      Proto =&gt; 'tcp',
      Timeout =&gt; 2
      );
  </code></pre>