RE: Test for empty list

2003-03-10 Thread Jeroen Lodewijks
Thanks all for the comments. Indeed I am interested in the empty list, not the print statement. I merely wanted to know if some sort special list operator existed. I am pretty sure that the code with 'last' is quicker than the ones with 'grep' but will do some tests on it. Cheers, Jeroen >===

last and grep - was: Re: Test for empty list

2003-03-09 Thread Katy Brownfield
On Sat, 08 Mar 2003 17:31:08 -0800, R. Joseph Newton <[EMAIL PROTECTED]> wrote: "Scott R. Godin" wrote: > #!/usr/bin/perl -w > > use strict; > > my @array = ('', 0, "", 1); > > my $hasTruth; > foreach (@array) { > if ($_ ){ > $hasTruth = "yezzindeedydo!"; > last; > } > } > if ($hasTr

Re: Test for empty list

2003-03-08 Thread R. Joseph Newton
"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

Re: Test for empty list

2003-03-08 Thread Scott R. Godin
> #!/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/

Re: Test for empty list

2003-03-07 Thread R. Joseph Newton
Jeroen Lodewijks wrote: > Hi all, > > Is there anybody out there who has a code snippet to test if a list is empty? > (a list is empty if all elements are either undefined or 0 or have an empty > string) > > Ofcourse I can do this: > > my $str = ''; > my $elem; > > my (@test) = (undef, ''); #put a

Re: Test for empty list

2003-03-07 Thread Rob Dixon
Hello Jeroen. Jeroen Lodewijks wrote: > Hi all, > > Is there anybody out there who has a code snippet to test if a list > is empty? (a list is empty if all elements are either undefined or 0 > or have an empty string) > > Ofcourse I can do this: > > my $str = ''; > my $elem; > > my (@test) = (unde

Re: Test for empty list

2003-03-07 Thread pete peterson
On Fri, 07 Mar 2003 05:53:54 -0500, Jeroen Lodewijks wrote: > Hi all, > > Is there anybody out there who has a code snippet to test if a list is empty? > (a list is empty if all elements are either undefined or 0 or have an empty > string) > > Ofcourse I can do this: > > my $str = ''; > my $el

Test for empty list

2003-03-07 Thread Jeroen Lodewijks
Hi all, Is there anybody out there who has a code snippet to test if a list is empty? (a list is empty if all elements are either undefined or 0 or have an empty string) Ofcourse I can do this: my $str = ''; my $elem; my (@test) = (undef, ''); #put any test data here foreach $elem (@test) {