in reply to printing the hash contents in mail

The simplest approach is to use Data::Dumper:

use Data::Dumper; my %hoh; my $info = Dumper \%hoh; ...

Replies are listed 'Best First'.
Re^2: printing the hash contents in mail
by Anonymous Monk on Jan 08, 2008 at 09:04 UTC
    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"; }

      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