Assign method call to hash value?
pierre masci
piemas25 at gmail.com
Tue Jan 29 14:09:16 GMT 2013
> The code
>
> return { passed => $passed, valid => $r->valid, missing => $r->missing,
> invalid => $r->invalid, unknown => $r->unknown };
>
> is equivalent to this
>
> return { 'passed', $passed, 'valid', $r->valid, 'missing', $r->missing,
> 'invalid', $r->invalid, 'unknown', $r->unknown };
>
> The bit inside the curly braces is not any kind of magical "hash
> constructor" but a list, plain and simple.
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.
More information about the london.pm
mailing list