use Perl<spanclass="synConstant">6</span>::Say<spanclass="synComment">;</span>
use YAML::Syck<spanclass="synComment">;</span>
use WebService::Simple<spanclass="synComment">;</span>
use XML::Simple<spanclass="synComment">;</span>
use utf<spanclass="synConstant">8</span><spanclass="synComment">;</span>
use Encode<spanclass="synComment">;</span>
use Config::Auto<spanclass="synComment">;</span>
use Net::Twitter<spanclass="synComment">;</span>
# === Until what ID <span class="synStatement">number</span> <span class="synStatement">do</span> I <span class="synStatement">get</span> from my favorites ===
my $recent_id <spanclass="synStatement">=</span><spanclass="synConstant"></span><spanclass="synComment">; # variant for storing the recent-obtained ID number</span>
# Read <span class="synStatement">the</span> ID <span class="synStatement">number</span> from <span class="synStatement">the</span> configuration file, .get_tumblr,
my $config <spanclass="synStatement">=</span> Config::Auto::parse<spanclass="synSpecial">(</span><spanclass="synConstant">".get_tumblr"</span><spanclass="synSpecial">)</span><spanclass="synComment">;</span>
my $response <spanclass="synStatement">=</span> $tumblr->get<spanclass="synSpecial">(</span> { <spanclass="synStatement">type</span> =><spanclass="synSpecial">'</span><spanclass="synIdentifier">quote</span><spanclass="synSpecial">'</span><spanclass="synIdentifier">,</span> num =><spanclass="synSpecial">'</span><spanclass="synIdentifier">50</span><spanclass="synSpecial">'</span> } <spanclass="synSpecial">)</span><spanclass="synComment">;</span>
my $data <spanclass="synStatement">=</span> XMLin<spanclass="synSpecial">(</span> $response->content <spanclass="synSpecial">)</span><spanclass="synComment">;</span>
my @ids<spanclass="synStatement">=</span><spanclass="synStatement">sort</span> keys %{ $data->{posts}->{post} }<spanclass="synComment">;</span>
# === 取得した XML データを操作する処理 ===
foreach my $id <spanclass="synSpecial">(</span>@ids<spanclass="synSpecial">)</span> {
next <spanclass="synStatement">if</span><spanclass="synSpecial">(</span>$id <spanclass="synStatement"><=</span> $recent_id<spanclass="synSpecial">)</span><spanclass="synComment">;</span>
my $text <spanclass="synStatement">=</span> encode<spanclass="synSpecial">(</span><spanclass="synSpecial">'</span><spanclass="synIdentifier">utf-8</span><spanclass="synSpecial">'</span><spanclass="synIdentifier">,</span> $data->{posts}->{post}->{$id}->{<spanclass="synConstant">"quote-text"</span>} <spanclass="synSpecial">)</span><spanclass="synComment">;</span>
my $url <spanclass="synStatement">=</span> encode<spanclass="synSpecial">(</span><spanclass="synSpecial">'</span><spanclass="synIdentifier">utf-8</span><spanclass="synSpecial">'</span><spanclass="synIdentifier">,</span> $data->{posts}->{post}->{$id}->{<spanclass="synConstant">"quote-source"</span>} <spanclass="synSpecial">)</span><spanclass="synComment">;</span>