Skip to content

Instantly share code, notes, and snippets.

@kentaro
Created November 11, 2011 12:08
Show Gist options
  • Save kentaro/1357857 to your computer and use it in GitHub Desktop.
Save kentaro/1357857 to your computer and use it in GitHub Desktop.
使ってないポートを取得する (Perl) ref: http://qiita.com/items/1018
#!/usr/bin/env perl
use strict;
use warnings;
use v5.14;
use IO::Socket::INET;sub empty_port () {
my $sock = IO::Socket::INET->new(
Prot => 'tcp',
Listen => 1,
(($^O eq 'MSWin32') ? () : (ReuseAddr => 1)),
);
my $port = $sock->sockport;
$sock->close;
$port;
}say empty_port;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment