On Fri, 19 Nov 1999, Jeffrey Baker wrote:

> I don't care whether Perl has allocate memory or not.  All I care about
> is whether or not there are any defined entries in the list, which I
> think is most clearly expressed as 'if (defined $list[0])'.  What is
> more clear than that?  'if (@list)' could certainly work because an
> empty list evaluates to 0 in a scalar context.  But the code doesn't
> look like what I am intending to do.

Eh, did I miss something?  If you really really want to test whether there
are any defined entries anywhere in an array then just testing the
definedness of the first entry isn't going to help.  If you really wanted
to do that you could do:

if (grep {defined} @list)

which does what you say you want.  'if (defined $list[0])' would only
check the first entry.  'if (@list)' would return true if '@list = (undef,
undef)'.


-Dave



/*==================
www.urth.org
we await the New Sun
==================*/

Reply via email to