#!perl $port="COM9"; sysopen(COM,$port,O_RDWR) || die "Can't open $port $^E"; $length=1024; while(1){ print ">"; $cmd=; if($cmd=~/^(x|q|exit|quit)$/is){last;} $cmd =~s/[\r\n]+$//; print "Cmd: $cmd\n"; my $packcmd=pack("A*",$cmd); print "Send: $packcmd\n"; syswrite(COM,$packcmd); #sends $string to COM1 print "Reading...\n"; #code to read data from port sysread(COM,$buf,$length); #read $length bytes print "Buf: $buf\n"; $received = unpack("C*",$buf); #unpack them print "Receive: $received\n"; } exit;