use strict; use warnings; my $hashref = { "key" => "value" }; local *foo = $hashref; printf("keys=%d\n", scalar(keys(%foo)));