I recently registered accounts on Twitter and Identi.ca. However, when I want to post a message on both, I have to manually copy and paste each message from a site to the other.
What I propose is to write a little Perl script to automate that process, so that each message that you write is automatically sent to both Twitter and Identi.ca.
I found the base for such a script on Dave Jacoby's blog. He actually did most of the work so there'll be very little change to make (Thanks Dave).
There are some CPAN modules to install (Net::Twitter from Chris Thompson and Modern::Perl from chromatic). That'll be a good example of using the cpan command line in Strawberry Perl.
Install Net::Twitter CPAN module on Strawberry Perl
This CPAN module is the keystone of Dave's script. It is a Perl interface to twitter.com.
To install the module in Strawberry Perl, follow those instructions:
- Open a DOS shell (cmd.exe)
- type cpan to open the cpan shell
- type m Net::Twitter (beware, CPAN module names are case-sensitive) to get help about the module.
- If it is not installed, you will get a message like this one:
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/C/CT/CTHOM/CHECKSUMS
Module id = Net::Twitter
CPAN_USERID CTHOM (Chris Thompson
CPAN_VERSION 2.06
CPAN_FILE C/CT/CTHOM/Net-Twitter-2.06.tar.gz
UPLOAD_DATE 2009-01-26
INST_FILE (not installed)
- Type install Net::Twitter to start the install process.
- If like me, you didn't have it installed, it will also try to add the JSON module dependency. This JSON format looks interesting by the way, please remind me to go check it back later.
- Ignore all the warnings and chose default options when prompted.
- If all goes well after the install is finished, you should get the following response to m Net::Twitter:
Database was generated on Fri, 06 Feb 2009 21:31:03 GMT
Module id = Net::Twitter
CPAN_USERID CTHOM (Chris Thompson
CPAN_VERSION 2.06
CPAN_FILE C/CT/CTHOM/Net-Twitter-2.06.tar.gz
UPLOAD_DATE 2009-01-26
MANPAGE Net::Twitter - Perl interface to twitter.com
INST_FILE C:\strawberry\perl\site\lib\Net\Twitter.pm
INST_VERSION 2.06
Run the same process for Modern::Perl (current version is 1.02).
I didn't get any problem installing those modules on my machine. Hope all goes smoothly for you also.
I noticed is that ActivePerl was still associated with .pl files (StrawberryPerl was installed after it). You'll need to change that association to c:\strawberry\perl\bin\perl.exe.
French expression of the day:
"une clef de voƻte": a keystone
Next posts:
- twit.pl: using the Net::Twitter module
- Improving on the Perl template
- How to install and use Google Analytics on your Blogger blog
- Perl help resources
- POD
Didn't know which would be the best place to put this.
ReplyDeleteThanks for reading me. Thanks for referencing me. Thanks for taking and extending my code.
One of things I dislike about Perl is that the general feel is "I'd rather make tools that make tools than make tools" approach, which leaves many re-invented wheels made from the same modules. Some people are trying to change that, such as Andy Lester's App::Ack (available on CPAN), which is almost grep++. More to the point, there's blt, or bash loves twitter, a command line Twitter tool that seems to be fully-featured. Since I have Twitux and Spaz and the web page, I just needed the send-a-twit functionality.
http://search.cpan.org/dist/blt/bin/blt
Don't know if it works with identi.ca.
Hi Dave,
ReplyDeletethanks for stopping by.
I am new to the Perl community but it seems to me that it's ok if many people write the same little programs as long as it is built on top of a common module.
You do not reinvent the wheel as all the functionalities are already available on CPAN. You just code what I would call the "applicative" part where you use the provided module functions that you need.
Perl makes it almost as quick to write a short script as to find the equivalent script and learn how to use it. Plus you get the satisfaction of creating new code and understanding how it works so that you can improve on it easily.
At least, that's the way I see it with my very little overview.
Rebol can do that in 2 lines see http://reboltutorial.com/blog/rebol-twitter-update/
ReplyDeleteHow does your Rebol tutorial teach me anything about Perl?!!
ReplyDeleteAlso, your example doesn't support Identi.ca so your statement is not even true ;p