my $count = 10; my $key = 'test'; #tie %hash, 'Tie::File::AsHash', 'abc.csv', split => ':' or die "Problem tying %hash: $!"; foreach my $family (keys %TV) { $count++; my $record = ""; my $rec = $TV{$family}; my $key = $family . $rec->{series}; for $person ( @{ $rec->{members} } ) { $record .= $person->{name}."," . $person->{role}. "," . $person->{age} . "," . $rec->{series} . "," . $rec->{nights}[0]; } print "\n Key: $key \n"; print "\n Record: $record \n"; $hash{$key} = $record; if ( $count%10 == 0 ) { sleep(10 ); print "\n Record counter => [$count] \n"; print "\n Process Status:" . ( ( memory_use()/1024 )/1024 ) ."MB \n"; %hash = (); # if we comment it memory constant } } #----for 1----#