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
>===
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
"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
> #!/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/
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
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
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
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) {