in reply to Casting magic - how to write numbers to the serial port

I guess you need to send a byte value. See chr, or pack("C",...) (for values 0..255):

$ob->write(chr($x*10)); # or $ob->write(pack("C", $x*10));