in reply to are TypeGlob assingments to a lexical variables possible?

It's safer to do local *H than local %H, and particularly convenient here. Also, there's no reason to use our %H globally.
use strict; sub foo { my $Href = shift; our %H; local *H = $Href; # define the alias print $H{1}; }

The downside to using local *H is that you can't access $H, @H, &H, etc in foo.

Replies are listed 'Best First'.
Re^2: are TypeGlob assingments to a lexical variables possible?
by cems22 (Initiate) on Sep 26, 2006 at 02:51 UTC
    thanks. But I'm not sure why it is "safer" to localize *H than specifically %H. I guess what you are worried about that the passed in reference might not be a hash. Right?
      No, it's because it prevents bad things from happening if the parent %H is a tied variable or an alias to a tied variable.