$PortName = 'COM1'; $Baudrate = 9600; while ($cmd = shift @ARGV) { $PortName = shift @ARGV if $cmd eq '-p'; $Baudrate = shift @ARGV if $cmd eq '-b' } unless ($Port = new Win32::SerialPort($PortName) and $Port->are_baudrate(115200) and $Port->baudrate($Baudrate) and $Port->parity('none') and $Port->databits(8) and $Port->stopbits(2) and $Port->handshake('rts') and $Port->buffers(4096,4096) and $Port->binary(1) and $Port->xon_limit(3000) and $Port->xoff_limit(300) and $Port->rts_active(1) and $Port->write_settings) { $mw->messageBox( -message => "Can't open $PortName at $Baudrate baud.", -type => 'OK' ); print $^E; exit }