in reply to Counting bytes in an input stream instead of a file

What about just using the read method of your Win32::SerialPort object? Keep in mind it can return less than the number of characters you ask for (just like a standard read), so you'll probably want to call it in a loop.