You're nowhere creating an object my $port = Device::SerialPort->new( "/dev/ttyS1" );, so I'm not sure what you expect you code to do, or how opening the logfile is meant to be related to Device::SerialPort, or how this could ever have "worked as expected"...