if (! defined ($value)) { print 1 value not defined\n;}
if ($value eq ) { print 2 Found empty string ($value)\n; }
if ($value == 0) { print 3 Found a zero too ($value)\n; }
$value = '';
if (defined ($value)) { print 4 value now is defined but null ($value)\n;}
if ($value eq ) { print 5 Found
How can I count empty values in an array? This count
should not include zeros or non-empty values. Below
is my current script, but it isn't working properly.
map { $count++ if(!length($_)) } @expression;
... will count zero-length elements.
!c
===
Discreet
I think this is a fairly simple question...
How can I count empty values in an array? This count
should not include zeros or non-empty values. Below
is my current script, but it isn't working properly.
I appreciate any assitance that you may provide.
Thank you,
David
#!perl -w
#
To: [EMAIL PROTECTED]
Cc: 'David Byrne'
Subject: Re: empty versus zero
I prefer Lynn. Rickards' method to the others I've seen mentioned.
Testing whether the value is defined will always work quietly and
swiftly; several of the other tests proposed will generate warnings
under some conditions
Lynn. Rickards wrote:
Thanks Will but I'll own up to maybe not reading the spec closely
enough. Is the string to be considered empty? It passes defined()
nevertheless...as does the empty string ''. Embarrassing.
I think the string is not empty. It is just initialized to a string
containing
Of
Will of Thornhenge
Sent: Wednesday, August 13, 2003 8:36 PM
To: [EMAIL PROTECTED]
Cc: 'David Byrne'
Subject: Re: empty versus zero
I prefer Lynn. Rickards' method to the others I've seen mentioned.
Testing whether the value is defined will always work quietly and
swiftly; several of the other tests