use strict; sub generateList { my $ref; push @$ref, { funPtr => do { my $x = $_; sub { print "in $x\n" } } } for qw(foo bar); $ref; } my $gVar; sub Foo { my $listOfHashRef = generateList(); my $functionPtr; foreach (@$listOfHashRef) { $gVar = $_; $functionPtr = $gVar->{funPtr}; # Assert: $gVar has all of its values here $functionPtr->(); } } # Assert: The $gVar->{funPtr} does indeed point to Bar sub Bar { print "$gVar\n"; # Assert: $gVar is null } Foo(); Bar(); __END__ in foo in bar HASH(0x88a1660)