2013-08-12 37 views
1

我在发送邮件的perl文件里面有下面的HTML代码。邮件部分和html部分是好的,但是当我尝试在DATA中添加Perl代码时,它显示为$BStatus$AStatus!上述两个变量的值已经存在,我确认了它。如何在perl html表中显示值?

如何显示其值?

$tme=localtime(); 
$subject='Android Results'; 
use MIME::Lite; 
my $msg = MIME::Lite->new (
    Subject => $subject, 
    From => '[email protected]', 
    To  => '[email protected]', 
    Type => 'text/html', 
    Data => '<H1>Summary</H1><br> <table border="1"> <tr bgcolor="#87CEFA"> <th>Platforms</th> <th>BStatus</th> <th>AStatus</th> <th>Results</th> </tr> <tr> <th bgcolor="#87CEFA">123</th> <td>$kstatus</td> <td>$astatus</td> <td> <a href="http://xx.xxx.xx.xx/Android/123.html">123-Results</a> </tr> <tr> <th bgcolor="#87CEFA">atgs</th> <td>row 2, cell 2</td> <td>row 2, cell 3</td> </tr> <tr> <th bgcolor="#87CEFA">8765</th> <td>row 2, cell 2</td> <td>row 2, cell 3</td> </tr> <tr></table>' 
); 
$msg->send(); 
+0

我建议你看看[模板工具包](http://template-toolkit.org/)。 –

回答

1

Perl不会在单引号字符串内插入变量。

用途:

  • 双引号的字符串
  • 其中一个替代语法的双引号中的字符串,如qq[...]
  • 一个适当的模板系统
+0

谢谢。当我用作“$ astatus”时,perl将它打印出来!当数据被用作引号Data =>“xxx”时,我得到语法错误。 – ramki067

+0

谢谢昆汀。它使用qq()。我是否也知道如何在我的代码中使用html表格中的if else语句? – ramki067

+2

如果你想要那么多的逻辑,那么使用一个真正的模板语言。 Template-Toolkit是事实上的标准。 – Quentin