#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; use JSON::XS; my $json = '{ "local": { "tomcat": { "general": { "catalina_home": "somewhere/tomcat/current", "install_dir": "somewhere/tomcat/8.5.20", "name": "Tomcat Web Application Server", "version": "1.8u131" }, "instances": { "instance_name": { "catalina_base": "somewhere/tomcat_instances/instance_name", "port": { "http": 18081, "https": 19081 }, "unix_group": "tmcuser", "unix_user": "tomcat1" }, "instance_name2": { "catalina_base": "somewhere/tomcat_instances/instance_name2", "port": { "http": 18082, "https": 19082 }, "unix_group": "tmcuser", "unix_user": "tomcat2" } } } } }'; my $data = decode_json($json); say for keys %{ $data->{local}{tomcat}{instances} };