#!/usr/bin/perl use strict; use Win32::SerialPort; #my @valid_com_ports; foreach my $port_to_open ( map{"COM$_"}1..32) { print "trying $port_to_open\n"; eval { my $PortObj = new Win32::SerialPort ($port_to_open) or print "unable to open $port_to_open\n"; }; }