warningsperlperl5.10

Getting rid of warnings for undefined values when using Chart module


I'm using Chart module to generate charts in PNG format from CSV data:

enter image description here

It works well, the charts look okay, but I get warnings for the undef values (there are 3 such values at the end of the above diagram):

#  ~/txv3.pl "./L*TXV3*.csv"  > /var/www/html/x.html
Generating chart: L_B17_C0_TXV3LIN_PA3_TI1_CI1
Use of uninitialized value $label in length at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3477, <> line 69.
Use of uninitialized value in subroutine entry at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3478, <> line 69.
Use of uninitialized value $label in length at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3477, <> line 69.
Use of uninitialized value in subroutine entry at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3478, <> line 69.
Use of uninitialized value $label in length at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3477, <> line 69.
Use of uninitialized value in subroutine entry at /usr/share/perl5/vendor_perl/Chart/Base.pm line 3478, <> line 69.

I need to get rid of these warnings as they are useless here and they make the log of my Hudson-job unreadable.

So I've tried (using perl 5.10.1 on CentOS 6.4 / 64 bit):

#!/usr/bin/perl -w
use strict;
....

$pwrPng->set(%pwrOptions);
$biasPng->set(%biasOptions);

my $pwrPngFile = File::Spec->catfile(PNG_DIR, "${csv}_PWR.png");
my $biasPngFile = File::Spec->catfile(PNG_DIR, "${csv}_BIAS.png");

{
        no warnings;

        $pwrPng->png($pwrPngFile, $pwrData);
        $biasPng->png($biasPngFile, $biasData);
}

But the warnings are still printed.

Any suggestions please?


Solution

  • In your Hudson-job, install a handler for the warn signal that filters warnings so the ones you know about won't show up.

    BEGIN { 
        $SIG{'__WARN__'} = sub { my $w = shift; warn $w if $w !~ m|/Chart/Base.pm| };
    }