No-no-no. Of course I created this object. And suddenly I realized I have no logfile. So I started to cut my script to minimal reproducible size. And so I came to this minimal script you see here in the post.
My actual question was not about how to read from a serial port. I just wondering why its not writing to file when I use mentioned perl module.
Comment on Re^2: 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.