in reply to Checking Port Open or Close

You can use IO::Socket::PortState module. I used this module only.