in reply to Re: printing the hash contents in mail
in thread printing the hash contents in mail

Hi
Thanks for the reply. but the code u gave prints the contents as below. VAR1 = { '' => { 'last_used' => '2007/12/20', 'user_name' => 'xyz', 'host_name' => 'nett1' } }; But I need to print the contents as the below code does. foreach (sort keys %hoh){ print "$_ "; my $tmp_hash = $hoh{$_}; foreach (sort keys %$tmp_hash){ print $$tmp_hash{$_}; print " "; } print "\n"; }

Replies are listed 'Best First'.
Re^3: printing the hash contents in mail
by Corion (Patriarch) on Jan 08, 2008 at 09:12 UTC

    Then why didn't you say so in the first place?

    Instead of printing, just collect all your data into the string:

    my $info; foreach (sort keys %hoh){ my $data = "$_ "; my $tmp_hash = $hoh{$_}; foreach (sort keys %$tmp_hash){ $data .= $$tmp_hash{$_} . " "; } $info .= $data . "\n"; } print "$info"; # here you would append that to your mail body