Re: dereferencing



On Mon, Oct 29, 2007 at 05:21:52PM -0700, Tom Phoenix wrote:

On 10/29/07, Jeremy Kister <perl-04@xxxxxxxxxxxxxxxx> wrote:
On 10/29/2007 7:23 PM, Aaron Priven wrote:
my $hashref = \%hash;

But as near as I can tell, there is no way to do the reverse
operation: making a "my %hash" that is an alias for a hash reference.

my %newhash = %{$hashref};

You have made a copy of the hash. I do not believe that that is what
the original poster wished, which I think would be a new hash that the
old reference points to. I don't think that what the original poster
wants is even possible, but I can't see any reason to need it, either.

Perhaps something like Data::Alias, for example, might do the trick.

--
Paul Johnson - paul@xxxxxxxx
http://www.pjcj.net
.



Relevant Pages

  • Re: Using lock_keys with strict and bless
    ... > use strict; ... You seem to be confused about how Perl modules work. ... $this as a hash, because it isn't a hash reference - or any reference ...
    (comp.lang.perl.misc)
  • Re: checking hashref for value
    ... It turns XML into a nested hash ... structure where the hash values can be a hash reference, ... If a tag may be repeated ... ...
    (perl.beginners)
  • Re: Self referencing hash
    ... You should also call it something better than HASH because the % ... you should use a hash reference, and if you have array-like core data just make ... one of the hash values an anonymous array. ... I feel very strongly that software should be written primarily for readability. ...
    (perl.beginners)
  • Re: Self referencing hash
    ... You should also call it something better than HASH because the % ... you should use a hash reference, and if you have array-like core data just make ... one of the hash values an anonymous array. ... basically there is a sub like this: ...
    (perl.beginners)
  • Re: Using lock_keys with strict and bless
    ... > You seem to be confused about how Perl modules work. ... > $this as a hash, because it isn't a hash reference - or any reference ... Your bless() statement blesses an anonymous hash into ...
    (comp.lang.perl.misc)