in reply to Constant Hashref Strangeness
If you wish to force Perl to interpret a set of braces as an anonymous hash composer rather than a BLOCK in a situation where it otherwise wouldn't, you should use the unary (+) operator. So your code becomes:
sub make_hashref3 { +{ %{ make_hashref() }, boo => 'too', }; }
If this looks ugly to you, use return:
sub make_hashref3 { return { %{ make_hashref() }, boo => 'too', }; }
I added semicolons to both examples for added clarity, though they are certainly optional.
|
|---|