Here's a quick way to get the last 10 Twitter messages (Tweets?) from the MarsPhoenix lander. The script requires XML::RSS::Parser::Lite, but I have no doubt that there are lots of other ways to do it.

I threw this together quickly for my wife after she read today's NYTimes article on the lander's use of Twitter. We're not cool enough to actually do Twitter, so this is an easy way to get her some recent messages. (Sure, she could just add the RSS feed itself to a browser or aggregator, but that wouldn't be using Perl, now would it?)

At the moment, the script is pretty minimal, but it would be easy to format more from here for inclusion in an email, etc. Check it out if you're curious.

#!/usr/bin/perl use strict; use warnings; use XML::RSS::Parser::Lite; use LWP::Simple; my $xml = get( "http://twitter.com/statuses/user_timeline/14693823.rss" ); die "No connection to MarsPhoenix. Try later.\n" unless defined $xml; my $rss = new XML::RSS::Parser::Lite; $rss->parse( $xml ); print $rss->get( 'title' ) . " - Last ten updates from MarsPhoenix:\n" +; foreach my $number ( 0..9 ) { my $item = $rss->get( $number++ ); print $item->get( 'title' ) . "\n"; }

In reply to Get updates from MarsPhoenix via Twitter & Perl by telemachus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.