#!/usr/bin/env perl use 5.010; use strict; use warnings; use JSON; my ($json_file, %json_wanted) = @ARGV; open my $json_fh, '<', $json_file or die "Can't open $json_file: $!"; my $json_text = <$json_fh>; close $json_fh; my $json_array_ref = decode_json $json_text; TEST_HASH: for my $test_hash (@$json_array_ref) { for my $wanted_key (keys %json_wanted) { my $test_value = $test_hash->{$wanted_key}; next TEST_HASH unless defined $test_value; next TEST_HASH unless "$json_wanted{$wanted_key}" eq "$test_value"; } for my $key (sort keys %$test_hash) { say $key, ': ', $test_hash->{$key}; } say '-' x 60; }