for ($i = 0; $i <= 65535; $i++) { print "port $i\n"; system "this takes 45 seconds to timeout"; sleep 2; kill ('INT', $$); }