Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

how to take a hash reference from main::,

by rfb (Sexton)
on Jan 04, 2001 at 03:55 UTC ( #49646=perlquestion: print w/replies, xml ) Need Help??

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
is there a way I can dereference it with so I dont have to use double dollar signs?
  • 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};

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://49646]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2021-12-05 14:15 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (31 votes). Check out past polls.