develooper Front page | perl.perl5.porters | Postings from August 2001

Re: [ID 20010827.004] qw// documentation says a list is created

Thread Previous | Thread Next
Michael G Schwern
August 27, 2001 14:43
Re: [ID 20010827.004] qw// documentation says a list is created
Message ID:
On Mon, Aug 27, 2001 at 10:29:46AM -0500, Ren Maddox wrote:
> The documentation of qw// states that a list is created.  It needs
> to be reworded in terms of context.  Here's one attempt:

>        qw/STRING/
>                Evaluates to a sequence of comma-separated,
>                single-quoted sub-strings extracted out of STRING,
>                using embedded whitespace as the delimiters.

I'm with Ronald.  The original description was better.

>                In list context, it can be understood as being roughly
>                equivalent to:
>                    split(' ', q/STRING/, -1);
>                the difference being that it happens at compile time.
>                In scalar context, it evaluates to the final sub-string
>                of the sequence.

That's actually what a list does in scalar context (as opposed to an
array, which returns it's number of elements.)  Commonly confused.
The clarification is good, especially since split() doesn't behave
that way.


Michael G. Schwern   <>
Perl6 Quality Assurance     <>	     Kwalitee Is Job One
We can also varify who belongs in the Kingdom of God and who doesn't with other
source of available personal records and by the will of family members.
	     --Alex Chiu, Immortality Guy

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About