> From: Shigeya Suzuki <shigeya@foretune.co.jp>
>
> Hi,
>
> I found following problem when I try to copy the reference of the
> result hash value (which I got from Sybase query).
>
> The subroutine "DBGetTableInfo2" work fine, but "DBGetTableInfo" not.
> Only difference is following:
>
> If I create anonymous hash and copy it, it work fine:
> But this if I grab a reference it is not:
>
> $cols{$data{name}} = \%data;
>
> Is this known behavior? Am I misunderstanding something?
>
The latter. Use
$cols{$data{name}} = { %data };
otherwise every %cols entry points at the _same_ instance of %data.
> shigeya
>
Tim.
>
> Hi,
>
> I found following problem when I try to copy the reference of the
> result hash value (which I got from Sybase query).
>
> The subroutine "DBGetTableInfo2" work fine, but "DBGetTableInfo" not.
> Only difference is following:
>
> If I create anonymous hash and copy it, it work fine:
> But this if I grab a reference it is not:
>
> $cols{$data{name}} = \%data;
>
> Is this known behavior? Am I misunderstanding something?
>
The latter. Use
$cols{$data{name}} = { %data };
otherwise every %cols entry points at the _same_ instance of %data.
> shigeya
>
Tim.