Assign method call to hash value?

Daniel Perrett perrettdl at googlemail.com
Tue Jan 29 21:12:38 GMT 2013


=head1 TANGENT

... about the design of context in perl.

I get how you can do things like {%original, %changes}, but is there a
reason why the => couldn't add some magic and assume scalar context on
whatever it precedes? The only case I imagine it would break would be
a hypothetical {%original,  key=> @odd_list }, but I don't know why
anyone would do that.

On 29 January 2013 14:18, gvim <gvimrc at gmail.com> wrote:
> On 29/01/2013 14:09, pierre masci wrote:
>>
>>
>> And (tell me if i'm wrong) it's also equivalent to this:
>>
>> my %result_hash = ( 'passed', $passed, 'valid', $r->valid, 'missing',
>> $r->missing, 'invalid', $r->invalid, 'unknown', $r->unknown );
>> return \%result_hash;
>>
>> where the brackets clearly show that it's a list.
>>
>
> The hash = list is not where my confusion originated. It came more from the
> fact that the list is still a list of scalars so I couldn't understand why
> adding another element to the list did not invoke a scalar context, that's
> all. Anyway, Dave Cross cleared it up, thanks.
>
> gvim


More information about the london.pm mailing list