while (1) { # Poll to see if any data is coming in my $char = $port->lookfor(); # If we get data, then print it # Send a number to the arduino if ($char) { print "Received character: $char \n"; } # Uncomment the following lines, for slower reading, # but lower CPU usage, and to avoid # buffer overflow due to sleep function. # $port->lookclear; # sleep (1); }