/ Published in: Perl
Lets say you have a small server. Its not really powerfull, it can not do much, but serve somebody some sites and an rss feed is allright.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#! /usr/bin/perl -w # Given that your blog post will look a bit like this and the "essay" for the rss feed is in # a html comment like this: ########################################################################################### # <html> # <h1>Hello World!</h1> # <!-- # # Hello World! # ~ Its is amazing what is possible with a bit of knowledge about # ~ C/C++, Perl, Shellscripting(Bash) and Unix based systems. # --> # Its is amazing what is possible with a bit of knowledge about # C/C++, Perl, Shellscripting(Bash) and Unix based systems. ########################################################################################### # The hash(#) and the tilde (~) are used as the line delimiters between RSS Feed Item # Title(#) and Content(~). use strict; use warnings; if( $ARGV[0]=~ m/\-\-help/ ) { } my $title=""; my $body=""; # parse blog post for rss feed data while(<$postH>) { if(m/\#/) { $title=$title.$_; } if(m/\~/) { $body=$body.$_; } } $title=~ s/\#//g; $body=~ s/\~//g; # put parse data in the feed string my $rssfile=""; while(<$rssfeedH>) { my $temp=$_; if( m/pastehere/ ) { $title="<title>\t".$title."</title>"; $body="<description>\t".$body."\n</description>"; my $guid=$ARGV[0]; #$guid=~ s:/?*\/?*::g; my $link="http://www.xxtjaxx.org/".$guid; $guid="<guid>\n\t".$guid."\n</guid>"; # Sun, 22 Nov 2009 02:15:48 +0000 my $date = `date +%a_,%d_%b_%Y_%k:%M:%S_%z`; $date=~ s/_/\ /g; my $pubdate="<pubDate>\t".$date."</pubDate>"; $temp="<!--pastehere-->\n"."<item>\n".$title."\n".$guid."\n".$body."\n".$pubdate."\n"."</item>\n"; } if ($temp =~ m/\n/ ) { $rssfile=$rssfile.$temp; } else { $rssfile=$rssfile."\n".$temp; } }