[Pdx-pm] implicit hashref return gone awry

Austin Schutz tex at off.org
Mon Dec 5 16:57:45 PST 2005

On Mon, Dec 05, 2005 at 04:49:08PM -0800, Randall Hansen wrote:
> this isn't working the way i expect, which means i have an  
> opportunity for education :)
>      sub four {
>          {
>              %{ one() },
>              label    => 'Bar',
>          };
>      }
> i expected it to return a hashref, but it returns a list.  this  
> appears to be related to the de-referencing of &one, since other  
> similar situations do return a hashref.  full code below illustrates  
> what i mean.

	It looks to me like perl is treating the {} inside sub four{} as
a code block instead of a hashref. I forget what the standard mechanism is
for forcing one vs. the other behavior. Probably something like enclosing
it in parens ({ stuff }).

	That's my guess :-)


More information about the Pdx-pm-list mailing list