SPUG: interesting while() behavior and hosting recs

John W. Krahn krahnj at telus.net
Thu Sep 30 23:59:49 CDT 2004


DeRykus, Charles E wrote:
> An array (AV) can meaningfully be evaluated in scalar context so
> I'd expect @empty to fail. However, () is a list in scalar context 

As Randal has pointed out many times and as the FAQ clearly states:

perldoc -q "What is the difference between a list and an array"
[snip]
        As a side note, there's no such thing as a list in scalar context.


> which doesn't behave in a predictable manner. 

That is because it doesn't exist.

In the expression:

while () { ... }

there is NO list.

As a side note, and has been recently discused on comp.lang.perl.misc, 
parentheses do not create a list.

http://groups.google.com/groups?threadm=UjE6d.138341%24D%25.46143%40attbi_s51



John
-- 
use Perl;
program
fulfillment


More information about the spug-list mailing list