Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Re: XML::RSS question

by mikeirw (Pilgrim)
on Jun 29, 2002 at 00:31 UTC ( #178181=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: XML::RSS question
in thread XML::RSS question

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?


Comment on Re: Re: Re: XML::RSS question
Re: Re: Re: Re: XML::RSS question
by Anonymous Monk on Jun 29, 2002 at 01:16 UTC
    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;
      One thing that may be causing you problems is concatenation in '$dirpath'. Try making these changes:
      my $template = $dirPath . "rss_outtemplate.htm"; my $fullOutfile = $dirPath . "rss.htm"; my $newName = $dirPath . $fileTag . "rss.htm"; my $rss_output = $dirPath . "rss.xml";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2015-07-03 16:35 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 (54 votes), past polls