in reply to Re^2: strange behaviour with Device::SerialPort
in thread strange behaviour with Device::SerialPort

Ah, sorry, that wasn't clear to me from your original post.

Maybe perl doesn't get around to flushing the file contents of L, because it prematurely quits for some reason related to Device::SerialPort (in some cleanup routine of the module?). Just a guess, though.

I would try to explicitly close the file. Or use strace to figure out what is or isn't happening under the hood.