On Wednesday, August 13, 2003, at 12:24 PM, Kenneth Graves wrote:
This should work:
if (length($value) == 0)
I'd prefer
if ($value eq '')
Also, you should change
split /\t/, $expression;
to
split /\t/, $expression, -1;
if you want to include trailing empty fields in your
Dear experts,
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 assistance that you may provide.
Thank you,
David
#!perl -w
I realize that, but the conditional he uses (!$value) *will* catch "0".
-T
>
>
> On Wednesday, August 13, 2003, at 01:21 PM, Timothy Kohl wrote:
> > (!$value)
> >
> > will catch zero "0" and undefs, but not "0.0".
>
> He doesn't want to catch either "0" or "0.0" .
>
_
On Wed, 13 Aug 2003, Kenneth Graves wrote:
> This should work:
>
> if (length($value) == 0) {
> $count += 1;
> }
Is there a reason you're not using a simple
$count++
that I'm not thinking of?
For that matter,
$count++ if ( length( $value ) == 0 );
is
How about this?
[EMAIL PROTECTED](join("",@X));
-Tim
>
> Dear experts,
>
> 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 prop
On Wed, Aug 13, 2003 at 12:55:16PM -0400, Chris Devers wrote:
> On Wed, 13 Aug 2003, Kenneth Graves wrote:
>
> > This should work:
> >
> >if (length($value) == 0) {
> >$count += 1;
> >}
>
> Is there a reason you're not using a simple
>
> $count++
>
> that I'm not
When you say doesn't work properly, is it miscounting.
More to the point
(!$value)
will catch zero "0" and undefs, but not "0.0".
-Tim (ignore my earlier post, please :)
>
> >
> > Dear experts,
> >
> > I think this is a fairly simple question...
> > How can I count empty
On Wednesday, August 13, 2003, at 01:21 PM, Timothy Kohl wrote:
(!$value)
will catch zero "0" and undefs, but not "0.0".
He doesn't want to catch either "0" or "0.0" .
___
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/bos
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On Wednesday 13 August 2003 11:56 am, David Byrne wrote:
Wouldn't the simple solution work? Just check for the defined-ness of the
element?
Vince
> #!perl -w
> # Count missing values
> while (my $line = <>) {
> chomp ($line);
> my ($probe_i
On Wednesday, August 13, 2003, at 12:55 PM, Vince Coccia wrote:
Wouldn't the simple solution work? Just check for the defined-ness of
the
element?
No. The element IS defined, but it is an empty string.
___
Boston-pm mailing list
[EMAIL PROTECTED]
http
Date: Wed, 13 Aug 2003 08:56:53 -0700 (PDT)
From: David Byrne <[EMAIL PROTECTED]>
How can I count empty values in an array? This count
should not include zeros or non-empty values.
This should work:
if (length($value) == 0) {
$count += 1;
}
$val
On Wed, 13 Aug 2003, David Byrne wrote:
> my $count = 0;
> foreach my $value (@expression) {
> if (!$value) {
> $count += 1;
> }
> }
my $count = grep {length == 0} @expression;
maybe.
Mike
--
[EMAIL PROTECTED]| The "`Stok' disc
12 matches
Mail list logo