I am a newbie to perl and have been trying to adapt some code with contain a subroutine that changes each time I execute it. The character entities are substuted to the html value until the script finally fails. (somewhere about the third execution). I dont know enough perl to see where the problem is. Any assistance will be truely appeciated.
original sub:
sub load_styles
{
my $small = "small";
my $smallxx = "x-small";
if($ENV{HTTP_USER_AGENT} =~ /msie/i and $ENV{HTTP_USER_AGENT} !~ /mac/i){
$small = "x-small";
$smallxx = "xx-small";
}
my $styles = qq^
<script language="JavaScript"><!--
var pixels_width = window.screen.width;
var pixels_height = window.screen.height;
var nWidth= "640";
var nHeight="450";
if(pixels_width < 740){
nWidth = "540";
}
if(pixels_height < 540){
nHeight = "350";
}
var optionString = "titlebar=no,toolbar=no,status=yes,location=no,menubar=yes,resizable=yes,scrollbars=yes,";
optionString += "height=" + nHeight + ",width=" + nWidth;
optionString += ",screenX=10,screenY=10,top=10,left=10";
var psWindow = null;
function winOpen(url){
if (!psWindow || psWindow.closed) {
psWindow = window.open(url,"Display",optionString);
} else {
// window already exists, so bring it forward
psWindow.location.href=url;
psWindow.focus();
}
}
// -->
</script>
<STYLE TYPE="text/css">
<!--
BODY {font-family: verdana, arial, helvetica, sans-serif; font-size: $small;}
TR, P, TD, TH, OL, UL, LI { font-family: verdana, arial, helvetica, sans-serif; font-size: $smallxx; }
H1 { font-size: 145%; color: #1E227E; font-family: verdana, arial, helvetica, sans-serif; }
H2 { font-size: 130%; color: #1E227E; font-family: verdana, arial, helvetica, sans-serif; }
H3 { font-size: 115%; font-family: verdana, arial, helvetica, sans-serif; }
H4 { font-size: 100%; color: #36469b; font-family: verdana, arial, helvetica, sans-serif; }
H5 { font-size: 85%; font-family: verdana, arial, helvetica, sans-serif; }
H6 { font-size: 70%; font-family: verdana, arial, helvetica, sans-serif; }
PRE, TT, CODE { font-family: courier, sans-serif; font-size: $smallxx; }
A { color: #000099; font-size: $smallxx; }
A:visited { color: #000099; font-size: $smallxx; }
A:active {color:#333366;}
A:link {color:#000099; font-size: $smallxx; }
A:hover { font-weight: normal color: #930;}
-->
</STYLE>
^;
return $styles;
}
After execution:
the quotes change to their character entities amp quot.
Then in the next execution the ampersands are substituted with their entities and so on until the script fails.