[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Testing list?



On Wed, Jan 05, 2000 at 07:21:21PM +0000, Peter Haworth wrote:
> John Porter wrote:
> > 
> > Huh?  
> >      ( $a, $b, @c ) ||= ( 1, 2, 3, 4, 5 );
> > would be the same as
> >      ( $a, $b, @c ) or
> >      ( $a, $b, @c ) = ( 1, 2, 3, 4, 5 );
> 
> But ($a,$b,@c) is always true!

You might think so, but...

if (($a, $b, @c)) {
        print "yeah... why?\n"
} else {print "nope... ok.\n"
}
@c = (5);
( $a, $b, @c ) or ( $a, $b, @c ) = ( 1, 2, 3, 4, 5 );
print "$a\n$b\n@c\n";


produces:

nope... ok.


5


Changing C<@c = (5)> to C<$a = 5> produces:

nope... ok.
1
2
3 4 5

So, before assigment, the list appears not to be true, and becomes
true when the first element is assigned to, but not the last.

Make of this what you will...

dha
-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
This is Pop - XTC

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe