Perl Check Open Ports

I needed to check a list of jumphosts and see if they were linux or windows. I didn’t want to log in to each one manually and wanted the results of something like nmap saved into a CSV file. I could of grepped through nmap output, but it wouldn’t of formatted the way I wanted. Instead I wrote a small perl script to check for open ports on a list of domains or IPv4 addresses. Here is the perl script to check for open ports: