Re: dereferencing



On 10/29/07, Aaron Priven <aaron@xxxxxxxxxx> wrote:

I can do this:

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.

You mean, given a reference to a hash, create a named lexical hash
that that reference refers to? No, that's not possible. Why would you
even want to do that? Is it just a matter of convenience, so you can
avoid dereferencing?

As you found, you can manipulate the symbol table so that a name
refers to a hash from a reference, but lexical variables aren't in the
symbol table.

Cheers!

--Tom Phoenix
Stonehenge Perl Training
.



Relevant Pages

  • Re: hash two keys to one index
    ... What goes into the map are pairs of (reference to key, ... When I insert an object into the hash table, I pass in ... void insert(Object obj, int hash) throws HashTableFull ... int probe = 0; ...
    (comp.lang.java.programmer)
  • Re: Net::SFTP::Attributes
    ... when I ask a simple question on the correct usage of a module I would ... If $subref is specified, for each entry in the directory, $subref will ... be called and given a reference to a hash with three keys: ...
    (comp.lang.perl.modules)
  • Re: hash two keys to one index
    ... What goes into the map are pairs of (reference to key, ... When I insert an object into the hash table, I pass in ... void insert(Object obj, int hash) throws HashTableFull ... int probe = 0; ...
    (comp.lang.java.programmer)
  • Re: Hashes of Hashes
    ... group = STRING ... If I swap the order of the declarations, then all of the keys for the ... hash that is referenced by $Data. ... This is known as a "symbolic reference" - using the ...
    (perl.beginners)
  • My own handy Pocket Reference notes
    ... inside the covers of my Perl Pocket Reference over the years. ... To pass a only single hash to a subroutine: ...
    (comp.lang.perl.misc)