DailyRiczWest – behind the scenes v0.5

Newspaper MegaphoneWhew! Bit of a Perl coding session, best summed up by by my twitter comment:

Apologies in advance to “The Ladies” but Perl is like a Burlesque Dancer. Very Sexy and when she does her stuff, you just have to admire ;-)

It’s been a while (probably 1y+) since I’ve coded Perl and it just reminds me what a fickle language that it is! After searching probably 20+ various google searches, I’ve finally figured it all out:

#!/usr/bin/perl -w
# use strict;

use File::Copy;

$ifttt_favourites = ".../Dropbox/ifttt/favourites.txt";
$twitter_month = ".../Dropbox/Public/Twitter/2012/apr";
$templates = "../../templates";

copy($ifttt_favourites, "body.html") or die "$ifttt_favourites cannot be copied to $twitter_month";

open(BODY,"< body.html") or die("Cannot Read body.html");
open(NEW_BODY,"> newbody.html") or die("Cannot Write newbody.html");

while (<BODY>) {
    print NEW_BODY;

close NEW_BODY;
close BODY;

system("cat $templates/header.html newbody.html $templates/footer.html > daily.html");
system("rm body.html newbody.html");

Seems so simple now, but there is so much “noise” about how to code Perl to do even simple tasks like search and replace that it’s a bit mind boggling!

Anyway, I’m almost there with the “automation” (the only thing I had to do was manually edit the Page Title Properties – and that was only because I’m running out of time). I now have a “program” that I can extend to automatically create the DailyRiczWest. The thing that really strikes me about Perl (yet again) is it’s awesome simplicity – it’s just so much work to reach that stage when you’re effectively a novice… Any comment’s on my code are welcome and I’ll soon put it up on GitHub when I have some time, but meanwhile, this at least makes generating my “Papers” a bit simpler.

How this will fit in with Twitter’s “grand new control-oriented plan” remains to be seen, but at the end of the day, I’m just getting a feed from If This Then That, while they are allowed to provide it… How this will fare under the new Twitter API Nazi Regime remains to be seen…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s