A roughly-optimal (within reason) script in perl that will pull all tweets for a given user and write them to the console.
Designed for anyone requiring one-off mass retrieval of historical tweets for twitter users, as the standard API provides no easy access to data outside of the "latest" for any user. This code first requests the latest batch of tweets, determines the lowest ID and then requests the rest sequentially from highest to lowest. Twitter's API doesn't always return data in order, however the date and timestamps included with the results make it possible to sort properly after retrieval.
For anyone needing different output than the default tweet text to STDOUT, code in the custom_action subroutine can be modified to pick and choose which fields are required, and output them in any format and to any location, database or storage device supported by perl. For a list of keys accessible through $status->{key}, see the Twitter API page: user_timeline
my $posts_per_request = 125;sub custom_action {) routine to output data in whatever format/data storage method is required. Default: STDOUT tweet content only.$status->{field} e.g. Line 113: say $status->{text}. See twitter API docs for further field descriptions.