SPUG: interesting while() behavior and hosting recs

John W. Krahn krahnj at telus.net
Sun Oct 3 08:30:44 CDT 2004

Yitzchak Scott-Thoennes wrote:
> On Sun, Oct 03, 2004 at 04:09:32AM -0700, "John W. Krahn" <krahnj at telus.net> wrote:
>>Yitzchak Scott-Thoennes wrote:
>>>They are just there for reasons of precedence.  Parens really really
>>>really truly don't function as list constructors.
>>So in the expressions:
>>while ( () ) { print "this won't print\n" }
>>$count = () = $string =~ /\d+/g;
>>You are saying that there is no list?
> :)  For every rule, there's an exception; () is the exception here.
> But it doesn't work by way of some grammatical rule that what's inside
> () is a list; empty parens are handled in perl's grammar as a special
> case.  I guess you could look at it as the parentheses being required
> to delimit the empty list for which there is no other syntactic
> provision.

I concur.  :-)

Yet I could argue that, in the second example, if the parentheses did delimit 
an empty list then $count would always contain 0.


use Perl;

More information about the spug-list mailing list