CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
A simple script

 



grooverider21
Deleted

Mar 22, 2000, 3:19 AM

Post #1 of 2 (1107 views)
A simple script Can't Post

Hello...I'm trying to find what I think is some sort of template script.
Here's the situation. I want to be able to put regularly updated news into my website. The news comes from a feed at http://www.guardianunlimited.co.uk/Distribution/Artifact_Trail_Block/0,5184,44662-0-4,00.html
which is itself regularly updated. The source for this page looks as follows :-
<!-- Vignette StoryServer 4 Sat Feb 12 19:59:08 2000 -->
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
<TR><TD>
<font size="2" face="Geneva,Arial,sans-serif">
<B>
<A HREF='http://www.newsunlimited.co.uk/Distribution/Redirect_Artifact/0,4678,0-135987,00.html'
>
Ulster goes back to direct rule
</A>
</B><BR>
Peter Mandelson, the Northern Ireland Secretary, yesterday reluctantly announced the restoration of direct rule from midnight last night as Northern Ireland's unique experiment in inclusive government ended in angry farce after 72 days. <BR>
</font> </TD></TR>
</TABLE>
I want to be able to grab the headline (eg. Ulster goes back to direct rule) and the main body of the text (eg. Peter Mandelson, the...days) and put it into my web page (index.html).
I have tried to find a script that will do this but I think it's too simple for anyone to have bothered writing and posting the script.
I don't know any perl but have downloaded ActivePerl and am willing to devote some time to working out how this works. I haven't programmed since BASIC when I was about 11 .. but I like the look of perl. Nice that you don't have to number each command.

so .. 10 Print "Can anyone help ?"


perlkid
stranger

Mar 22, 2000, 11:28 AM

Post #2 of 2 (1107 views)
Re: A simple script [In reply to] Can't Post

  
So If I understand Correctly You just want to use a template for you news with perl so that the news is always up to date, Right?

If so (using perl) you can do this by using this code below

############################

#!/usr/bin/perl
$template="/path/to/cgi-bin/template.html";
print "Content-type: text/html\n\n";

$whatever = qq(<HTML> );
$whatever1 = <<ENDHTML;
<HTML>
ENDHTML
$whatever2 = "<font size = \"2\" color = \"FFFFF\">This Is A test</font>";

if (-e "$template"){
open(OPENING, "$template") &#0124; &#0124; die "I can't open $template";
@wholefile=<OPENING>;
foreach $line (@wholefile){
$line=~s/%whatever%/$whatever/g;
$line=~s/%whatever1%/$whatever1/g;
$line=~s/%whatever2%/$whatever2/g;
push (@openhtml,$line);
}}
print "@openhtml\n";

################################

It's not all that complicated but I Guess your on an NT server and I used this in Unix. But most perl will run on both platforms, That's why I gave you a few different methods for assigning html to a $scalar, use whatever one works. I pulled this out of a huge junk of code that was using this but you should have no problem. Just change the path to perl #!/usr/bin/perl to your perl path.

If you have any problems email me.

perlkid@olbis.com

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives