#! C:\perl\bin\perl.exe use strict; use warnings; use Win32::SerialPort ; my $count_out = 0; my $PortObj = new Win32::SerialPort ("COM1") || die "Can't open port\n"; $PortObj->baudrate(9600); $PortObj->parity("none"); $PortObj->databits(8); $PortObj->stopbits(1); $PortObj->handshake("none"); $PortObj->write_settings || undef $PortObj; my $stt = pack 'H16', 'FF010003005F630A' ; # $PortObj->write($stt); $count_out = $PortObj->write($stt); warn "write failed\n" unless $count_out; warn "write incomplete\n" if $count_out != length($stt); $PortObj->error_msg(1); $PortObj->user_msg(1); $PortObj->close || warn "Close Failed!\n"; undef $PortObj; # output from program: # C:\Users\Frank\Desktop>micro-2.pl # Write failed # Use of uninitialized value $count_out in numeric ne (!=) at C:\Users\Frank\Deskttop\micro-2.pl line 34. # Write incomplete