psini has asked for the wisdom of the Perl Monks concerning the following question:

I reduced the code to the minimum to reproduce the problem.

#!/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";

And this is the error I get:

sini@ordinalfabetix:~$ ./x.pl (in cleanup) Can't call method "setcflag" on an undefined valu +e at /usr/lib/perl5/Device/SerialPort.pm line 482 during global destr +uction. sini@ordinalfabetix:~$

Sub foo is not called anywhere but if I delete it the problem disappear. Same if I delete or replace its content.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

Replies are listed 'Best First'.
Re: Strange problem with Device::SerialPort
by zentara (Cardinal) on Jun 26, 2008 at 19:09 UTC
    If you search groups.google.com for 'Can't call method "setcflag" on an undefined' , you will find many posts. I'm too lazy to go thru them, but you can. :-)

    I'm not really a human, but I play one on earth CandyGram for Mongo

      Shame on me, I forgot rule two: Google rules.

      Double quoting the text reduce to 7 the number of results (my post here is the 4th!) and surely are related to my problem but give no solution (except the Hungarian one that I couldn't read).

      But I'm relieved by the fact that it is not the SerialPort hating me and that in CB I've been given a workaround: explicitly closing the port before program end.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."