Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: XML::RSS question

by mikeirw (Pilgrim)
on Jun 28, 2002 at 21:27 UTC ( #178155=note: print w/ replies, xml ) Need Help??


in reply to XML::RSS question

Hmmm...the code looks right. What exactly does it do when your RSS file contains 15 headlines?


Comment on Re: XML::RSS question
Replies are listed 'Best First'.
Re: Re: XML::RSS question
by Anonymous Monk on Jun 28, 2002 at 21:31 UTC
    Nothing =) It doesn't add any new entries or delete any old ones.
      I'm not sure what the problem is with the code you've posted. Are you trying to write out a RSS file, or just read one in? Can you post the rest of your script?
        I am writing a rss file. Here is the full code:
        ######################### # includes ######################### use strict; use warnings; use CGI qw(:standard); use XML::RSS; ######################### # vars ######################### my $dateStamp; my $dirPath = "C:/Inetpub/wwwroot/mywebsite/rss/"; my $newName = ''; my $passName = ''; my $currentDate; my $fullOutfile; ######################### # make a date stamp ######################### my ($sec, $min, $hour, $mday, $mon, $year) = localtime; $mon += 1; #this will change the month from a 0-11 format to a +useable 1-12 format $year += 1900; # year is number since 1900 - so we add 1900 to +get the full year. $dateStamp = "$year$mon$mday$hour$min"; # datestamp to identify + the entry ######################### # sub to get rss input from htm form and write it to a file ######################### sub getInput { my $title = param('title'); my $desc = param('desc'); my $full = param('full'); my $template = $dirPath. "rss_outtemplate.htm"; my $tempHTML =''; my $fullOutfile = "$dirPath.rss.htm"; $full =~ s/\r/<br><br>/g; # putting <br>'s in where there were cr' +s in the input ######################### # format the form data using a template ######################### open(FILEFULL, $template) or die ("Couldn't open template file - $ +template - $!\n"); while (<FILEFULL>) { s/xTitle/$title/g; s/xDesc/$desc/g; s/xfull/$full/g; $tempHTML .= $_; } close FILEFULL or die ("Couldn't close $template - $!\n"); ######################### # write the form data with template to the dump file ######################### open(FILESTOR,"> $fullOutfile") or die ("Couldn't open $fullOutfil +e - $!\n"); print FILESTOR $tempHTML; close FILESTOR or die ("Couldn't close $fullOutfile - $!\n"); return $fullOutfile } ######################### # rename the dump file with fileTag ######################### sub renameFile ($$){ my $fileTag = shift; my $fullOutfile = "$dirPath.rss.htm"; $passName = $fileTag. "rss.htm"; my $newName = $dirPath.$fileTag. "rss.htm"; rename $fullOutfile, $newName or die ("Couldn't rename rss out fil +e - $fullOutfile - $!\n"); return $passName; } ######################### # sub to write the rss file ######################### sub writeRss ($) { my $rss = new XML::RSS (version => '1.0'); my $rss_output = "$dirPath/rss.xml"; my $title = param('title'); my $desc = param('desc'); my $rss_link = shift; $rss_link = "http://www.mywebsite.com/rss/$rss_link"; $rss->parsefile($rss_output); pop(@{$rss->{'items'}}) if (@{$rss->{'items'}} == 15); $rss->add_item(title => $title, link => $rss_link, description => $desc, mode => 'insert' ); $rss->save($rss_output); } ######################### # wrap it all up ######################### sub writeAfter { print "Content-type: text/html\n\n"; print "Sucess - put something in here later ... a page to link bac +k to the site - stuff like that.\n" } ######################### # call subs ######################### getInput; renameFile ($dateStamp, $fullOutfile); writeRss ($passName); writeAfter; undef &main;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://178155]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-07-29 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls