jmcnamara / excel-writer-xlsx

Perl module to create Excel XLSX files.
https://metacpan.org/pod/distribution/Excel-Writer-XLSX/lib/Excel/Writer/XLSX.pm
Other
100 stars 51 forks source link

Warning on uninitialized value. #270

Closed shenyush closed 3 years ago

shenyush commented 3 years ago

I am getting

Use of uninitialized value $_[2] in addition (+) at /usr/share/perl5/vendor_perl/5.32/Excel/Writer/XLSX/Worksheet.pm line 2308.

Original code my $num = $_[2] + 0;

My workaround was my $num = $_[2]; $num += 0;

Thanks

jmcnamara commented 3 years ago

Thanks.

How did you generate that warning? With something like this?:

$worksheet->write_number( 0, 0, undef );
shenyush commented 3 years ago

Yes, that’s what I was doing, apparently the variable was null. Now I am not sure if this should be considered a bug or else.

Thanks.

On Sep 12, 2021, at 3:18 PM, John McNamara @.***> wrote:

Thanks.

How did you generate that warning? With something like this:

$worksheet->write_number( 0, 0, undef ); — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jmcnamara/excel-writer-xlsx/issues/270#issuecomment-917694446, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMTIF4DLLG446EP5EEPZZDUBT4JNANCNFSM5D26UW3Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

jmcnamara commented 3 years ago

Now I am not sure if this should be considered a bug or else.

It is probably more in the input error than bug category. It isn't intended that undef is treated implicitly as the number 0.

So for now may just put a check in your code to unsure that undef doesn't get passed to write_number().