私は Net::Twitter を使って Twitter メッセージにアクセスしています。現在、direct_message() はメッセージの配列を返します。私が見つけたのは、それが実際には配列の配列であることです(アカウントに基づいて、個々のメッセージに基づいています)。
結果からメッセージIDを出力するより良い方法を誰かが知っているかどうか知りたいですか? $msgs[0][0]{'id'} はメッセージIDを出力するため、配列の配列であるとしか考えていませんでした。データダンパーを実行すると、ハッシュの配列のように見えました。
foreach my $msg (@{$msgs[0]})
{
print $msg->{'id'} . "\n";
}
データ::ダンパーの結果
$VAR1 = [
{
'sender_screen_name' => 'text',
'recipient' => {
'friends_count' => 'text',
'follow_request_sent' => 'text',
'profile_background_image_url_https' => 'text',
'profile_sidebar_fill_color' => 'text',
'profile_image_url' => 'text',
'profile_background_color' => 'text',
'notifications' => 'text',
'url' => 'text',
'id' => 'text',
'is_translator' => 'text',
'following' => 'text',
'screen_name' => 'text',
'lang' => 'text',
'location' => 'text',
'followers_count' => 'text',
'statuses_count' => 'text',
'name' => 'text',
'description' => 'text',
'favourites_count' => 'text',
'profile_background_tile' => 'text',
'listed_count' => 'text',
'contributors_enabled' => 'text',
'profile_link_color' => 'text',
'profile_image_url_https' => 'text',
'profile_sidebar_border_color' => 'text',
'created_at' => 'text',
'utc_offset' => 'text',
'verified' => 'text',
'show_all_inline_media' => 'text',
'profile_background_image_url' => 'text',
'protected' => 'text',
'default_profile' => 'text',
'id_str' => 'text',
'profile_text_color' => 'text',
'default_profile_image' => 'text',
'time_zone' => 'text',
'profile_use_background_image' => 'text',
'geo_enabled' => 'text',
},
'id_str' => 'text',
'sender_id' => 'text',
'created_at' => 'text',
'text' => 'text',
'sender' => {
'friends_count' => 'text',
'follow_request_sent' => 'text',
'profile_background_image_url_https' => 'text',
'profile_sidebar_fill_color' => 'text',
'profile_image_url' => 'text',
'profile_background_color' => 'text',
'notifications' => 'text',
'url' => 'text',
'id' => 'text',
'is_translator' => 'text',
'following' => 'text',
'screen_name' => 'text',
'lang' => 'text',
'location' => 'text',
'followers_count' => 'text',
'statuses_count' => 'text',
'name' => 'text',
'description' => 'text',
'favourites_count' => 'text',
'profile_background_tile' => 'text',
'listed_count' => 'text',
'contributors_enabled' => 'text',
'profile_banner_url' => 'text',
'profile_link_color' => 'text',
'profile_image_url_https' => 'text',
'profile_sidebar_border_color' => 'text',
'created_at' => 'text',
'utc_offset' => 'text',
'verified' => 'text',
'show_all_inline_media' => 'text',
'profile_background_image_url' => 'text',
'protected' => 'text',
'default_profile' => 'text',
'id_str' => 'text',
'profile_text_color' => 'text',
'default_profile_image' => 'text',
'time_zone' => 'text',
'profile_use_background_image' => 'text',
'geo_enabled' => 'text',
},
'recipient_screen_name' => 'text',
'id' => 'text',
'recipient_id' => 'text',
}
];