FollowFriday для Twitter
Цель скрипта проста — он берёт последние 50 записей, выдирает оттуда твиттерчан и постит их ники под тегом #followfriday )
#!/usr/bin/perl -w use strict; use WWW::Curl::Easy; use Data::Dumper; use URI::Escape; my $login = q[skazkin]; my $password = q[password]; my $href = "http://twitter.com/statuses/friends_timeline.xml?count=50"; my $message_dummy = "#followfriday "; my (@posts, %tmp, @people); my $lenta = callTwitter({href=>$href}); while($lenta->{content} =~ /(@[a-z0-9_]+)/ig){ push(@people, $1); } @people = grep(!$tmp{$_}++, @people); while($#people != -1){ my $msg = $message_dummy; while(length $msg < 140){ last if $#people == -1; my $name = shift @people; if((length $name) + (length $msg) > 140){ push (@people, $name); last; } $msg .= $name.q[ ]; } push(@posts,$msg); } $href = "http://twitter.com/statuses/update.xml"; foreach(@posts){ callTwitter({ href => $href, post => "status=".uri_escape($_) }); sleep(1); } sub callTwitter { my $params = shift; my ($result, $retcode, $curl) = ('false',undef,undef); $curl = new WWW::Curl::Easy; $curl->setopt(CURLOPT_URL, $params->{href}); $curl->setopt(CURLOPT_USERPWD, $login.q[:].$password); $curl->setopt(CURLOPT_POST, 1) if $params->{post}; $curl->setopt(CURLOPT_POSTFIELDS, $params->{post}) if $params->{post}; open (my $tmp_for_curl, ">", \$result); $curl->setopt(CURLOPT_FILE,$tmp_for_curl); $retcode = $curl->perform; return {retcode => $retcode, content => $result}; }