$ perl -Mstrict -wE '
my $x;
say "\$x not defined: ", (! defined $x) ? "Y" : "N";
say "\$x not TRUE: ", (! $x) ? "Y" : "N";
$x = 0;
say "\$x not defined: ", (! defined $x) ? "Y" : "N";
say "\$x not TRUE: ", (! $x) ? "Y" : "N";
$x = 1;
say "\$x not defined: ", (! defined $x) ? "Y" : "N";
say "\$x not TRUE: ", (! $x) ? "Y" : "N";
'
$x not defined: Y
$x not TRUE: Y
$x not defined: N
$x not TRUE: Y
$x not defined: N
$x not TRUE: N
| [reply] [d/l] [select] |
I suppose that would be another way to write it
It is not. But in short, if you want to check if a variable is in false condition,
use if (! $var) {..., or unless ($var) {..., or the example I gave above.
A false condition includes 0, "" (empty string), and undefined value.
On the other hand, defined is checking a null condition (not initialized, undefed). In other words, a variable given "" or 0 also consider as defined, because value already inside. And a proper usage on defined should following a variable, like if ( defined $x ). In your code, ... !defined is checking with $_ which is what you read from <FH>, which I believe is not what you wanted.
"$z[7]" $z is Zipcode...
That's why I quoted my @z = 90005; in your code snip, as this is not even a proper array, thus there will be no $z[7] existed.
Finally, please read other's responds, you can't read Excel by simply open.... , not even CSV. Use a proper module for the job.
| [reply] [d/l] [select] |