in reply to Re: Supressing error messages on serial port open in Linux
in thread Supressing error messages on serial port open in Linux

{ no warnings 'redefine'; sub Device::SerialPort::carp { }; # no-op }

Please don't do it that way. Always localize the overwriting of subroutines:

{ no warnings 'redefine'; local *Device::SerialPort::carp = sub { # no-op }; $PortObj = new Device::SerialPort($port, 1) or next; } # carp works again

Replies are listed 'Best First'.
Re^3: Supressing error messages on serial port open in Linux
by pashanoid (Scribe) on Sep 05, 2011 at 05:31 UTC
    Works great! Error messages are goner! Thank you!
Re^3: Supressing error messages on serial port open in Linux
by pashanoid (Scribe) on Sep 05, 2011 at 05:52 UTC

    Ooops, now I'm getting this error:

    Name "Device::SerialPort::carp" used only once: possible typo at dial. +pl line 58.
    This is my code:
    eval "use Device::SerialPort; 1" or die $@; my $directory = '/dev'; opendir (DIR, $directory) or die $!; while (my $file = readdir(DIR)) { #print "$file\n"; push (@ports, "$directory/$file") if ($file =~ /ttyS/g); push (@ports, "$directory/$file") if ($file =~ /ttyUSB/g); } closedir(DIR); foreach my $port (@ports){ no warnings 'redefine'; local *Device::SerialPort::carp = sub {}; $PortObj = new Device::SerialPort($port, 1) or next; $PortObj->close; push(@ok_ports, $port); sleep (1); };

      This is a warning, not an error. See diagnostics. You can suppress that warning by disabling the warning:

      no warnings 'once';