wwe has asked for the wisdom of the Perl Monks concerning the following question:
I'm confused about the following problem: I'm going through an excel file using Spreadsheet::XLSX. I want to print out the content of the file. There some cells which are unused, but they are not empty in terms of excel but contain a single space character or a 0(zero).
I want to omit these cells. I tried to filter the with a statement (simplified) $cell eq '' or $cell == 0 and found out that this filters out cell which contain a 'normal' strings. After further investigation I know that the problem is the '==' comparison of a string to a 0 which returns true.
I would like to have an advice if this is an intended behavior and if yes why. Here is a small piece of code to reproduce the problem:
use strict; use warnings; my $string = 'abcd'; my $number = 0; if ($string == $number) { print "equal\n" } else { print "different\n" }
This gives me the following output:
Argument "abcd" isn't numeric in numeric eq (==) at _eq.pl line 8. equal
I would expect to get a 'different' printed out...
|
|---|