[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Javascript within perl question

Posted on 2006-11-02
7
Medium Priority
?
279 Views
Last Modified: 2013-12-25
A while back, my client had one of
their partners come up with a new theme for the site. It is heavily reliant
on Javascript. They asked me to integrate the theme with the existing site.
I wedged the code in as best I could and it seems to work fairly well on
their existing site. The page this file builds is:
http://www.hotel-online.com/Classifieds/index.pl .  You'll see it displays
pretty neatly. This site is running PERL 5.00503, Apache 1.3, and FreeBSD
4.3 (sorry, I misspoke on the phone).

I have loaded a new drive with FreeBSD 6.1, Apache 2.2.3, and PERL 5.8.8.
(It's not web-visible at the moment...) I've upgraded most of the other
relevant applications and libraries also. I've installed all the files from
the existing site and rewired a few paths, but most of the pages display as
they always have. Except for the page above.

Instead, it displays this code from about line 340 of the index.pl file at
the top of the page (in I.E, not Firefox):

0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i

In addition, it loses the formatting for the fonts, displays the text
centered, loses the reddish bar at the bottom and loses the gray background
in the bottom half of the page.

I'm guessing it's a difference in the PERL versions that does this.


Here is my code. index.pl

#!/usr/bin/perl

use CGI;

my $q = new CGI();

print $q->header();
my $STYLE = &style_sheet;
my $JAVASCRIPT = &javascript;
print $q->start_html( -title=>"Hotel Online Classifieds Hotel Online Home Page: Hospitality Industry, Gaming Industry, Lodging Forum, hotel employment, hospitality consultants, hotel product vendors, Hotel.Online, News", -style=>"$STYLE", -script=>"$JAVASCRIPT" );

print qq~

<body onLoad="MM_preloadImages('../gif/nav_welcomej.gif','../gif/nav_newsj.gif','../gif/nav_classifiedsj.gif','../gif/nav_forumj.gif','../gif/nav_onej.gif','../gif/nav_resourcesj.gif','../gif/nav_media_kitj.gif','../gif/nav_contactj.gif','../gif/falconon.gif','../gif/metamendon.gif')" >
<div align="center">



<!-- METAMEND TOP -->
<div align="center">

<!-- This begins the whole page table - all background -->

<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0" style="background-image:url(../gif/bgpagetop.jpg); background-position:top; background-repeat:no-repeat;">
      <tr>
            <td height="194" align="center" valign="top">

<!-- This begins the header -->

                  <table width="751" border="0" cellspacing="0" cellpadding="0">
                        <tr align="left" valign="top">
                              <td><a href="../index.html"><img src="../gif/logo.gif" alt="Hotel Online Homepage" width="360" height="164" border="0" lowsrc="Hotel Online Homepage"></a>
                              </td>
                              <td><img src="../gif/topbarimage.jpg" width="391" height="164">
                              </td>
                        </tr>
                  </table>

<!-- This begins the navbar table -->

                  <table width="751" border="0" cellspacing="0" cellpadding="0">
                        <tr align="left" valign="top">
                              <td width="88">
                                    <a href="../welcome.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navwelcome','','../gif/nav_welcomej.gif',1)"><img src="../gif/nav_welcome.gif" alt="Welcome" name="navwelcome" width="88" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="57"><a href="../News/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navnews','','../gif/nav_newsj.gif',1)"><img src="../gif/nav_news.gif" alt="News" name="navnews" width="57" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="97"><a href="../Classifieds/index.pl" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navclassified','','../gif/nav_classifiedsj.gif',1)"><img src="../gif/nav_classifieds.gif" alt="Classifieds" name="navclassified" width="97" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="66"><a href="../Views/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navforum','','../gif/nav_forumj.gif',1)"><img src="../gif/nav_forum.gif" alt="Forum" name="navforum" width="66" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="96"><a href="../Oneonone/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navone','','../gif/nav_onej.gif',1)"><img src="../gif/nav_one.gif" alt="One to One" name="navone" width="96" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="151"><a href="../Trends/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navresources','','../gif/nav_resourcesj.gif',1)"><img src="../gif/nav_resources.gif" alt="Industry Resources" name="navresources" width="151" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="84"><a href="../News/PressReleases1998_3rd/Aug98_BannerAds.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navmedia','','../gif/nav_media_kitj.gif',1)"><img src="../gif/nav_media_kit.gif" alt="Media Kit" name="navmedia" width="84" height="30" border="0"></a>
                              </td>
                              <td width="2"><img src="../gif/nav_spacer.gif" width="2" height="30">
                              </td>
                              <td width="98"><a href="mailto:richardljohnson\@hotel-online.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('navcontact','','../gif/nav_contactj.gif',1)"><img src="../gif/nav_contact.gif" alt="Contact Us" name="navcontact" width="98" height="30" border="0"></a>
                              </td>
                        </tr>
                  </table>
            </td>
      </tr>

      <tr>
            <td height="234" align="center" valign="top">

<!-- This table is the main two column table below the header and nav bar. -->

            <table width="751" height="300" border="0" cellpadding="0" cellspacing="0">
                  <tr>

<!-- This column is the left column with main text -->

                        <td width="751" align="center" valign="top" bgcolor="#E7E8E5">

<!-- This table is the page title  -->
                              
                              <table width="751" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                          <td>
                                                <h1><span class="style5">C</span>lassifieds </h1>
                                          </td>
                                    </tr>
                              <td>

<!-- Here begins the main editable area -->


<P>
<center>
<b>Welcome to our on-line Classifieds for the Hospitality Industry!</b>
<p>
Pick a category to browse or submit an ad:
</center>
<P>
<ul>
~;

@nams = split(/\n/,`/usr/local/bin/psql -t -A -d hotel.online -c "select name from topics"`);

for $t (0 .. $#nams) {
 $q = $nams[$t];
 $q=~ s/\ +$//g;
 $q=~ s/\ /+/g;
 print qq~<li> <a href="shew.pl?TOPIC=$q">$nams[$t]</a></li>~;
}

print qq~
</ul>

</td></tr></table>
</center>

</body>
</html>
~;







print <<EOMEOM;

<!-- Here ends the main editable area -->
                                    <p>&nbsp;</p>
                                    <p>&nbsp;</p>
                              </td>
                        </tr>
                  </table>
            </td>
      </tr>
<!-- Here begints the footer table -->

      <tr>
            <td align="center" valign="top">
                  <table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="C73D0D" id="footer">
                        <tr>
                              <td align="center">
                                    <a href="../index.html" class="style1">home</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../welcome.html" class="style1">welcome</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../News/">news</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="../Classifieds/index.pl" class="style1">classifieds</a>&nbsp;&nbsp; |&nbsp;&nbsp; <a href="../Views/" class="style1">forum</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../Oneonone/" class="style1">one-on-one</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="../Trends/" class="style1">industry resources</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="../News/PressReleases1998_3rd/Aug98_BannerAds.html" class="style1">media kit</a><br><a href="mailto:richardljohnson\@hotel-online.com" class="style1">contact us</a> <br>
<img src="../gif/redline.gif" width="416" height="15">
                              </td>
                        </tr>
                        <tr>
                              <td align="center" class="style1 style6">COPYRIGHT &copy; 2005 Hospitality Internet Media, L.L.C. dba Hotel Online <br>
2475 Northwinds Parkway, Suite 325, Alpharetta, GA 30004<br>
&nbsp;<br>
Telephone: 678.802.5304 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fax: 678.802.5309&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; email: <A href="mailto:Sharon\@hotel-online.com" class="style1">sharon\@hotel-online.com</A>
                              </td>
                        </tr>
                  </table>

<!-- Metamend/Falcon ad -->

                  <table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="C73D0D">
                        <tr>
                              <td width="162" align="center">&nbsp;</td>
                              <td width="163" align="center">
                                    <a href="http://www.falcon-software.com" target="_blank" onMouseOver="MM_swapImage('imgFalcon','','../gif/falconon.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="../gif/falconoff.gif" alt="Falcon Software Company Inc." name="imgFalcon" width="101" height="53" border="0" lowsrc="Falcon Software Company, Inc."></a>
                              </td>
                              <td width="211" align="center" valign="top"><a href="http://www.metamend.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgMetamend','','../gif/metamendon.gif',1)"><img src="../gif/metamendoff.gif" alt="Metamend Search Engine Optimization" name="imgMetamend" width="174" height="42" border="0"></a>
                              </td>
                              <td width="165" align="center">&nbsp;</td>
                        </tr>
                  </table>
            </td>
      </tr>
</table>
</div>



EOMEOM


sub style_sheet {
my $STYLE=qq~
body {
      background-color: #a9abb5;
      background-image:url(../gif/bgpage.jpg);
      background-position:center;
      background-repeat:repeat-y;
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
}
.more {padding-left: 62px; text-transform: uppercase;}
.more a:link { font-family: Georgia, "Times New Roman", Times, serif; font-size: 10px; color: #822809; text-decoration: none; line-height: 16px}
.more a:visited { font-family: Georgia, "Times New Roman", Times, serif; font-size: 10px; color: #121C6A; text-decoration: none; line-height: 16px}
.more a:hover { font-family: Georgia, "Times New Roman", Times, serif; font-size: 10px; color: #822809; text-decoration: underline;line-height: 16px}
.input {border: 1px solid #AFA1A1; font-family: Arial, Helvetica, sans-serif; font-size: 12px;}

.smallCaps:link,
.smallCaps:visited,
.smallCaps:active{
      font-family: Georgia, "Times New Roman", Times, serif;
      font-size: 12px;
      font-weight: bold;
      text-transform:uppercase;
      color: #844840;
}
.smallCaps:hover{
      font-family: Georgia, "Times New Roman", Times, serif;
      font-size: 12px;
      font-weight: bold;
      text-transform:uppercase;
      color: #FFFFFF;
}
h1 {letter-spacing: 1px; color: #79627F; font-family: Georgia, "Times New Roman", Times, serif; font-size: 24px; font-weight: normal; font-variant: small-caps; font-style: oblique; margin-left: 35px;}
h2 {letter-spacing: 1px; color: #79627F; font-family: Georgia, "Times New Roman", Times, serif; font-size: 18px; font-weight: normal; font-variant: small-caps; font-style: oblique; margin-left: 35px;}
.date {color: #79627F; font-family: "Times New Roman", Times, serif; font-size: 13px; font-weight: normal; text-transform:uppercase ; padding-left: 35px;}
.style5 {font-size: 30px}
li {list-style-image: url(../gif/bullet.gif); font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #333333; border-bottom: 1px dotted #792609; margin-right: 30px; margin-left: 20px;margin-top: 10px; padding-bottom: 10px; }
li a:link { font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #333333; text-decoration: none}
li a:visited { font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #121C6A; text-decoration: none}
li a:hover { font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #822809; text-decoration: underline}
p {font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #333333; margin-right: 30px; margin-left: 0px;margin-top: 10px; padding-bottom: 10px; }
.styleAA {font-family: Georgia, "Times New Roman", Times, serif; font-size: 11px; color: #333333; margin-right: 30px; margin-left: 0px;margin-top: 10px; padding-bottom: 10px; }

#sidebar {
padding: 5px;
height:100px;
}

#sidebar li{
      list-style-image: url(../gif/bullet2.gif);
      font-family: Georgia, "Times New Roman", Times, serif;
      font-size: 13px;
      color: #814C48;
      border-bottom: 1px dotted #792609;
      font-weight: bold;
      line-height: 10px;
      margin:10px 10px;
      padding:none;
      list-style-position: inside;
}
#sidebar a:link,
#sidebar a:visited,
#sidebar a:active
{ color: #814C48; text-decoration: none}
#sidebar a:hover { color: #FFFFFF; text-decoration: underline}

#footer a:link,
#footer a:visited,
#footer a:active
{ font-size: 13px; color: #FFFFFF; text-decoration: none; font-variant:small-caps;}
#footer a:hover { font-size: 13px; color: #FFFFFF; text-decoration: underline; font-variant:small-caps;}

.formInput {
border: 1px solid #AFA1A1;
height: 18px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
color:#989898;
padding-left: 3px;
}
.style6 {color: #FFFFFF}
~;
return $STYLE;
}

sub javascript {
my $JAVASCRIPT=qq~

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//
~;
return $JAVASCRIPT;
}

0
Comment
Question by:dk4210
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:dk4210
ID: 17861092
Anyone ... Someone????
0
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 672 total points
ID: 17863784
I managed to run this with Firefox also. Pelr code looks fine. My guess it that IE is not handling this line

<script type="text/javascript">//<![CDATA[ .....

The syntax looks a bit old fashioned. You shouldn't need to use a CDATA block to enclose javascript
0
 
LVL 8

Assisted Solution

by:Perl_Diver
Perl_Diver earned 664 total points
ID: 17864157
teraplane,

the CGI module is adding the CDATA stuff.


dk4210,

change this:

print $q->start_html( -title=>"Hotel Online Classifieds Hotel Online Home Page: Hospitality Industry, Gaming Industry, Lodging Forum, hotel employment, hospitality consultants, hotel product vendors, Hotel.Online, News", -style=>"$STYLE", -script=>"$JAVASCRIPT" );

print qq~

<body onLoad="MM_preloadImages('../gif/nav_welcomej.gif','../gif/nav_newsj.gif','../gif/nav_classifiedsj.gif','../gif/nav_forumj.gif','../gif/nav_onej.gif','../gif/nav_resourcesj.gif','../gif/nav_media_kitj.gif','../gif/nav_contactj.gif','../gif/falconon.gif','../gif/metamendon.gif')" >
<div align="center">

to:

print $q->start_html( -title=>"Hotel Online Classifieds Hotel Online Home Page: Hospitality Industry, Gaming Industry, Lodging Forum, hotel employment, hospitality consultants, hotel product vendors, Hotel.Online, News", -style=>{ -code=>$STYLE }, -script=>{ -code=>$JAVASCRIPT }, -onLoad=> "MM_preloadImages('../gif/nav_welcomej.gif','../gif/nav_newsj.gif','../gif/nav_classifiedsj.gif','../gif/nav_forumj.gif','../gif/nav_onej.gif','../gif/nav_resourcesj.gif','../gif/nav_media_kitj.gif','../gif/nav_contactj.gif','../gif/falconon.gif','../gif/metamendon.gif')" );


print qq~
<div align="center">


that will eliminate the second body tag in the source code that might be messing up the display in some browsers.
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 17864226
more messed up html code here:

print qq~
</ul>

</td></tr></table>
</center>

</body>
</html>
~;







print <<EOMEOM;

<!-- Here ends the main editable area -->
                              <p>&nbsp;</p>
                              <p>&nbsp;</p>
                         </td>
                    </tr>
               </table>
          </td>
     </tr>
<!-- Here begints the footer table -->

     <tr>
          <td align="center" valign="top">
               <table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="C73D0D" id="footer">
                    <tr>
                         <td align="center">
                              <a href="../index.html" class="style1">home</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../welcome.html" class="style1">welcome</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../News/">news</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="../Classifieds/index.pl" class="style1">classifieds</a>&nbsp;&nbsp; |&nbsp;&nbsp; <a href="../Views/" class="style1">forum</a>&nbsp;&nbsp; | &nbsp;&nbsp;<a href="../Oneonone/" class="style1">one-on-one</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a href="../Trends/" class="style1">industry resources</a> &nbsp;&nbsp;| &nbsp;&nbsp;<a href="../News/PressReleases1998_3rd/Aug98_BannerAds.html" class="style1">media kit</a><br><a href="mailto:richardljohnson\@hotel-online.com" class="style1">contact us</a> <br>
<img src="../gif/redline.gif" width="416" height="15">
                         </td>
                    </tr>
                    <tr>
                         <td align="center" class="style1 style6">COPYRIGHT &copy; 2005 Hospitality Internet Media, L.L.C. dba Hotel Online <br>
2475 Northwinds Parkway, Suite 325, Alpharetta, GA 30004<br>
&nbsp;<br>
Telephone: 678.802.5304 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fax: 678.802.5309&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; email: <A href="mailto:Sharon\@hotel-online.com" class="style1">sharon\@hotel-online.com</A>
                         </td>
                    </tr>
               </table>

<!-- Metamend/Falcon ad -->

               <table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="C73D0D">
                    <tr>
                         <td width="162" align="center">&nbsp;</td>
                         <td width="163" align="center">
                              <a href="http://www.falcon-software.com" target="_blank" onMouseOver="MM_swapImage('imgFalcon','','../gif/falconon.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="../gif/falconoff.gif" alt="Falcon Software Company Inc." name="imgFalcon" width="101" height="53" border="0" lowsrc="Falcon Software Company, Inc."></a>
                         </td>
                         <td width="211" align="center" valign="top"><a href="http://www.metamend.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgMetamend','','../gif/metamendon.gif',1)"><img src="../gif/metamendoff.gif" alt="Metamend Search Engine Optimization" name="imgMetamend" width="174" height="42" border="0"></a>
                         </td>
                         <td width="165" align="center">&nbsp;</td>
                    </tr>
               </table>
          </td>
     </tr>
</table>
</div>



EOMEOM



you print the </body> and </html> tags and then print more html code. Move the </body> and </html> tags the end of the html output.

also you need to add '#' symbol to your hexadecimal color codes so all browsers will render them correctly, like here:

<table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="C73D0D" id="footer">

should be:

<table width="751" border="0" cellpadding="0" cellspacing="10" bgcolor="#C73D0D" id="footer">


I'd go over all that html/css/javascript code with a fine tooth comb and correct all errors.  And since you are really using html 4 code you should print an html 4 header instead of an XHTML 1 header which the CGI module prints by default. This will cause CGI to print an  HTML 4.01 Transitional header:

use CGI qw/-no_xhtml/;



0
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 664 total points
ID: 17864328
Besides fixing the html, css, and javascript code, I'd recommend using an html template.  98% of your code is hard coded static html and the only perl code that is really doing anything is the few lines that create the category links.  If you use HTML::Template, you can very easily seperate your html layout from you db query and link generation.

http://search.cpan.org/~samtregar/HTML-Template-2.8/Template.pm

Here's the complete Perl script.

#!/usr/local/bin/perl

use strict;
use warnings;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use HTML::Template;

print "Content-Type: text/html\n\n";

my $template = HTML::Template->new(filename => 'hotel_online.tmpl');

# personally, Id change this to use the DBI module to do the query which will provide better control over the error handling.
my @nams = split(/\n/,`/usr/local/bin/psql -t -A -d hotel.online -c "select name from topics"`);

my @links;

foreach my $category (@nams) {
   my %link;
   my $text = $category;
   $category =~ s/\s+$//;
   $category =~ s/\s+/+/g;
   $link{link} = $category;
   $link{text} = $text;
   push @links, \%link;
}

$template->param(category => \@links);
print $template->output;

# end of script

The only change, besides the already suggested corrections, that you need to make in the html file is to replace the links with this loop.

Pick a category to browse or submit an ad:
 </center>
 <P>
 <ul>
   <TMPL_LOOP NAME="category">
       <li><a href="shew.pl?TOPIC=<TMPL_VAR NAME='link'>"><TMPL_VAR NAME="text"></a></li>
   </TMPL_LOOP>
 </ul>
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question