#!/usr/bin/perl use strict; use warnings; use Device::SerialPort; my $comm; sub foo { $comm=0; } $comm=new Device::SerialPort('/dev/ttyS0') or die "Error opening device\n"; #### sini@ordinalfabetix:~$ ./x.pl (in cleanup) Can't call method "setcflag" on an undefined value at /usr/lib/perl5/Device/SerialPort.pm line 482 during global destruction. sini@ordinalfabetix:~$