I am trying to send a html email (report) about the values in a hash. But I couldnt print the hash values in a table format. I am using HTML::Mason to execute my perl commands (looping through a hash) and printing it in the end of report. But how can I execute my perl code to loop through hash inside html ?
use HTML::Entities;
use Mail::Sendmail;
use MIME::Lite;
use Term::ANSIColor;
use Time::localtime;
use HTML::Mason;
my $ti = localtime;
my ($day,$month,$year)=($ti->mday,$ti->fullmonth,$ti->year);
# DEFINE A HASH
%coins = ( "Quarter" , 25,
"Dime" , 10,
"Nickel", 5 );
$html = <<END_HTML;
<table border='1'>
<th>Keys</th><th>Values</th>
<%perl>
while (($key, $value) = each(%coins)){
</%perl>
<tr><td>$key</td>;
<td>$value</td></tr>;
<%perl>
}
</%perl>
</table>;
END_HTML
$msg = MIME::Lite->new(
from => 'abc@mydomain.com',
To =>'def@mydomain.com',
Subject =>'Report',
Type =>'multipart/related'
);
$msg->attach(
Type => 'text/html',
Data => qq{
<body>
<html>$html</html>
</body>
},
);
$msg->attach(
Type => 'image/gif',
Id => 'banner.jpg',
Path => 'C:\Users\Pictures\banner.jpg',
);
MIME::Lite -> send ('smtp','xxxs.xxxx.xxxxx.com' );
$msg -> send;