[Pdx-pm] defined $var->{key} changes $var in to a hashref?
benh
ben.hengst at gmail.com
Mon Feb 22 15:47:34 PST 2010
ok I guess I should rephrase, I understand ~why~ it's doing this
($var->{} builds out the hash, not defined), but it's not quite what
my ~expectation~ was. What I was thinking was going to happen was more
along the lines of:
grep{$x = $_; $x->{key}} $var
so that $var was not touched... though I can't think of a good way for
defined to effectively clone in place as the transformation would have
already happened as far as defined was concerned.
On Mon, Feb 22, 2010 at 15:37, Andy Lester <andy at petdance.com> wrote:
>
> On Feb 22, 2010, at 5:35 PM, benh wrote:
>
>> eq_or_diff( $var, undef );
>>
>> ok( ! defined $var->{key} );
>>
>> eq_or_diff( $var, undef );
>
> Yes, because you're forcing $var to be a hashref because you want to get something out of it. You want to check to see if it's a hashref first.
>
> --
> Andy Lester => andy at petdance.com => www.theworkinggeek.com => AIM:petdance
>
>
>
>
>
--
benh~
http://three.sentenc.es/
More information about the Pdx-pm-list
mailing list