这是我的代码:
#!/usr/bin/perl
use Net::Twitter;
use JSON;
use LWP::Simple;
use XML::Bare;
use Data::Dumper;
# keys for twitter
$consumer_key = "key";
$consumer_secret = "key";
$token = "key-key";
$token_secret = "key";
# As of 13-Aug-2010, Twitter requires OAuth for authenticated requests
my $nt = Net::Twitter->new(
traits => [qw/API::RESTv1_1/],
# traits => [qw/API::Search/],
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
access_token => $token,
access_token_secret => $token_secret,
);
$UserID = 46562311;
my $IDs = $nt->friends_ids({user_id => $UserID});
print Dumper $IDs->{ids};
输出结果为:
$ VAR1 = [ 1243478918, 472407213, 1152523333, 18080969, 36843988, 24467012, 322990625, 15492359, 2244340904, 22938914, 151180133, 58545637, 62513246, 28412286, 5746452, 17104751, 1636590253, 25073877, 8161232, 2384071, 13, 93957809, 22330739, 44196397, 132961448, 754500, 94384796, 59604041, 386854967, 15485441, 190617492, 226237599, 114485232, 190486752, 18645153, 326350862, 546915948, 1927794380, 244360712, 254674228, 43593, 17242168, 17268874, 117539435, 116737145, 326642243, 1010165784, 19583340, 7936522, 166739404, 50374439, 593893034, 1244526223, 783214, 382267114, 299743215, 16129880, 20536157, 17006157, 2249234689, 26761757, 17919972, 2244994945, 1526228120, 11348282, 14159148, 50393960, 1339835893, 409685881, 2469260288, 1012494116, 270816968, 813286, 2546660556, 518542127, 794611698, 108962082, 1626691956, 734314441, 20351217, 1692371666, 774980724, 865699670, 1958038938, 826539409, 805891104, 14749606, 391858548, 26693596 ];
如何计算此数组的长度?我使用"长度$ ID-> {ids}"但它只给了我21这显然是错误的。