Perl's Net::Twitter module made this a snap

No Comments

I wanted to have my Twitter account (not mine, but for a friend, y'know) automagically post a random song lyric as my Status Update once or twice a day, which turned out to be Real Easy thanks to Twitter's open API and the fine people at CPAN, who have written a module called Net::Twitter.

I came up with this, and I think it's working, although I won't really know until after a week or two of seeing what it posts.

#!/usr/bin/perl -w

use strict;

use Net::Twitter;

my $quote;
my $file = 'randomquotes.txt';

open FILE, $file;
srand;
rand($.) < 1 && ($quote = $_) while ;
close FILE;

my $twit = Net::Twitter->new({username=>"username", password=>"password" });
my $result = $twit->update({status => $quote});

So far, so good, right?

Just put your quotes into a textfile called 'randomquotes.txt', one quote per line, and you're off and running.

I'm partially doing this because it's neat, but partially because maybe it will make me seem busier than I actually am...

Be the first to write a comment!