"Scott R. Godin" wrote:

> > #!/usr/bin/perl -w
> >
> > use strict;
> >
> > my @array = ('', 0, "", 1);
> >
> > my $hasTruth;
> > foreach (@array) {
> >   if ($_ ){
> >     $hasTruth = "yezzindeedydo!";
> >     last;
> >   }
> > }
> > if ($hasTruth) {print "$hasTruth has truth\n";}
> > else {print "Does not have truth";}
> >
> >
> > Joseph
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my @array = ('', 0, "", 1);
>
> foreach (@array) {
>         print $_ ? "$_ has truth\n" : "$_ has no truth\n;
> }

The problem is that you kept the bsth water and through out the baby.  The original 
poster was interested only in empty lists.  The print statements at the end of my code 
were only debug code to indicate the value assigned to the variable $hasTruth, which 
was the payload.

The design, which may have seemed heavy to you, served a purpose by providing shortcut 
evaluation on failure--finding a true element in the list.  Since you can never make a 
shortcut evaluation in  affirming a categorical [this list has no valid elements, this 
list is all valid elements] the appropriate efficiency is to shortcut out on negation.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to