develooper Front page | perl.macperl | Postings from August 2005

[MacPerl] using references with hashes

Thread Previous
From:
Louis Pouzin
Date:
August 5, 2005 23:48
Subject:
[MacPerl] using references with hashes
Message ID:
200508051613.j75GD3Wm015427@ares.enst.fr
On Wed, 3 Aug 2005 18:21:14 -0400, Joshua Juran wrote:

>my $ref = \$H{one}{two}{three}[0];
># Either of these should work
>delete %$ref{four} if exists %$ref{four};
>delete $ref->{four} if exists $ref->{four};

Joshua, I tried those tests and got the following diags:

delete %$ref{four} if exists %$ref{four}; #Can't use subscript on hash deref
delete $ref->{four} if exists $ref->{four}; #Not a HASH reference

It's the same with MacPerl 5.20r4 and Perl 5.008004.

Finally, what works is:

delete $$ref->{four} if exists $$ref->{four}; #ok

Thanks


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About