my @Counts = (); my $vidcount = 0; my $idees = ''; foreach my $vidid (@vidids) { if (!($vidcount % 50)) { fetchCounts($idees); $idees = ''; } else { $idees .= ','; } $idees .= $vidid; $vidcount++; } fetchCounts($idees); exit; sub fetchCounts { my $idees = shift; if ($videes ne '') { my $uri = "https://www.googleapis.com/youtube/v3/videos?part=i +tems(viewCount)&id=$idees&key=$API_KEY"; ##$idees is the 50-max comm +a separated string of video IDs my $result = get($uri); my $json = decode_json($result); for my $i( @{$json->{items}} ) { push @Counts, $i->{viewCount}; } } }
In reply to Re: Next 50 array elements during each loop?
by dbander
in thread Next 50 array elements during each loop?
by Bman70
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |