sub Clear{ my $item=$_[0]; $item=~s/^\s+//; $item=~s/\s+$//; return $item; } sub Txn_Extract{ my $name_of_file=$_[0]; my $hash_ref=$_[1]; $hash_ref=Clear($hash_ref); #Here something goes wrong. When I remove this line %DATA_HASH gets populated properly. Need to know what happens when I clear the $hash_ref variable with above sub Clear. my @row; . .. . . } sub Main { Txn_Extract (file.txt,\%DATA_HASH); print Dumper \%DATA_HASH }