rfb has asked for the wisdom of the Perl Monks concerning the following question:

Currently I'm
$session = \$main::session;
but that means I have to access the hash with
$$session->{'supa'}
is there a way I can dereference it with so I dont have to use double dollar signs?
-rfb
  • Comment on how to take a hash reference from main::,

Replies are listed 'Best First'.
Re: how to take a hash reference from main::,
by danger (Priest) on Jan 04, 2001 at 04:03 UTC

    If $main::session alread holds a reference to a hash, then just assign that value (the reference) to the new variable (do not introduce another level of references):

    %main::hash = (one => 1, two => 2, three => 3); $main::session = \%main::hash; my $session = $main::session; print $session->{two};