#!/usr/bin/perl use strict; use warnings; use Mojo::UserAgent; use feature 'say'; my $url_food = 'https://api.nal.usda.gov/fdc/v1/food/170581?api_key=Oc4bD3tFWgPAscW0R0gBRivwqEdt0N182PXCGNQO'; my $ua_food = Mojo::UserAgent->new; my $json_food = $ua_food->get($url_food)->res->json; say $json_food->{fdcId}; foreach my $nutrients( @{$json_food->{'foodNutrients'}} ){ say $nutrients->{'nutrient'}{'name'}; }