in reply to Passing hash to package sub and get it returned ..

did you recognize that there are two variables called temp in your sub?
$temp is used nowere, instead you use only %temp.
i changed your code a bit, so it looks like this
use strict; use warnings; my $hash = test::this(); for my $box (keys %{$hash}){ print "this is box $box\n"; for my $par (keys %{$$hash{$box}}){ print "this is partition $par\n"; # for my $sec (keys %{$hash->{$box}->{$par}}){ # print "this is section $sec\n"; # } } } package test; sub this { my $Dbox = "Dbox"; my $DDD = "DDD"; my %temp; $temp{"Dbox"}{$DDD}= "DDD"; for my $box (keys %temp){ print "this is box $box\n"; for my $par (keys %{$temp{$box}}){ print "this is partition $par\n"; # for my $sec (keys %{$temp{$box}->{$par}}){ # print "this is section $sec\n"; # } } } return \%temp; }

use always use strict; use warnings; when you are messing around with things you dont fully understand.
read perlreftut and perldsc->HoH.