Rob Dixon <[EMAIL PROTECTED]> wrote:
> John W. Krahn wrote:
>>
>> No need to create and then dereference an anonymous array, you
>> can get list context for the count like this:
>>
>> my $count = () = /\b$soundex\b/g;
>
> Thanks John: I've never seen that before. By rights I would have
> thought it should assign either zero (as the number of elements
> in an empty list) or undef (as the last element of an empty list)
> to $count. Do you know where this is documented?
>
It's in "perlop" under "Assignment Operators":
Similarly, a list assignment in list context produces the
list of lvalues assigned to, and a list assignment in
scalar context returns the number of elements produced by
the expression on the right hand side of the assignment.
^^^^^ ^^^^ ^^^^
Kind of unintuitive at first, since none of the other types
of assignment work this way...
--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]