LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PERL: parsing html news entries into perl (https://www.linuxquestions.org/questions/programming-9/perl-parsing-html-news-entries-into-perl-742052/)

xand49 07-22-2009 03:44 PM

PERL: parsing html news entries into perl
 
Hello,

I'm currently writing a micro perl cms system to allow a company to update a news marquee, i'm currently taking form input and formatting the output into a html file.

What i'm wondering is how i can make it have 3 news entries where creating a new entry will erase the last one in the list.

I've not used perl for a few years and was amateur at best the last time i dabbled with it, i'll put my current code and a sample of the html entrys below.

the .pl
Code:

#!/usr/bin/perl
use CGI;
print "Content-type: text/html\n\n";
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $FormData);
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $FORM{$name} = $value;}
print <<END_HTML;
<html><head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body><marquee height="211" direction="up" scrollamount="1" scrolldelay="0" OnMouseOver="this.stop();" OnMouseOut="this.start();">
 <table border="0"><tr>
 <td width="1254" valign="top">
 <span class="date">$FORM{'dayte'}</span>
<br>
 <span class="title"><a href="news.html" target="_blank">$FORM{'title'}</a></span></td>
</tr><tr>
  <td><span class="ingress">$FORM{'content'}</span>    </td>
<tr>
 <td width="1254" valign="top">
</table></marquee></body></html>
END_HTML

a sample of the formatted html
Code:

<td width="1254" valign="top">
<span class="date">2009-29-05</span>
<br>
<span class="title"><a href="news.html" target="_blank">Healthcare Sector Profile added</a></span></td>
</tr><tr>
  <td><span class="ingress">We are pleased to announce our new Healthcare sector profile PDF is now available online. Simply go to '<strong>Download latest brouchre</strong>' and click on the '<strong>Healthcare Secto</strong>r' button.</span>    </td>

any help with this matter would be much appreciated.

thanks for your time in advance!


All times are GMT -5. The time now is 03:49 PM.