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>
<td width=\"340\">
<div align=\"left\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">$display_item_value</font></div>
</td>
<td width=\"150\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">
$add_link | $modify_link | $delete_link </font></td>
</tr>";


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

Code:
$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 :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
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
HTML_CODE
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.

Philip
------------------
Limecat is not pleased.