Gossamer Forum
Home : General : Perl Programming :

html in perl code

Quote Reply
html in perl code
I've been getting some strange characters and corrupted layouts appearing in my html pages. Part of the html code is generated by a perl script and I was wondering which of the following methods is correct and if there is anything that might be causing the problems. My script loops through and combines abot 40+ of the $output before returning the final result.

Method 1:
$output.="<tr bgcolor=$backgound_color>\n";
$output.="<td width=\"150\">\n";
$output.="<div align=\"right\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b>$display_item_name</b></font></div></td>\n";
$output.="<td width=\"340\">\n";
$output.="<div align=\"left\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$display_item_value</font></div></td>\n";
$output.="<td width=\"150\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$add_link | $modify_link | $delete_link </font></td></tr>\n";

Method 2:
$output.="<tr bgcolor=$backgound_color>
<td width=\"150\">
<div align=\"right\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><b>$display_item_name</b></font></div>
<td width=\"340\">
<div align=\"left\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$display_item_value</font></div>
<td width=\"150\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">
$add_link | $modify_link | $delete_link </font></td>

Any ideas?
Thank You.
Quote Reply
Re: [jai] html in perl code In reply to
I would personally use something like;

$var = qq|

<html> can "" here and anything you want, as long
as you don't used a pipe


This evades the problems of having to escape quotes and stuff :)


Andy (mod)
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] html in perl code In reply to
Thanks Andy!!
That does the job.
In fact, I also tried the following as well -

$var = <<HTML_CODE;
something here
something here
Quote Reply
Re: [jai] html in perl code In reply to
that's what I prefer, but it seems really odd and un-Perl-like that a bare word is the closing deliminator in a block, and that it MUST appear at the beginning of a line, by itself.

Limecat is not pleased.