use strict; use warnings; use JSON; use JSON::Parse 'parse_json'; print "Loading API.\n"; my $json = `curl -k --silent -u admin:password https://url...`; print "API is loaded.\n"; my $decoded_json = parse_json ($json); my $input = $ARGV[0]; chomp $input; my ($item, $mac, $value); foreach $item (@$decoded_json) { $mac = $item->{address}; if ($input eq "active") { $value = $item->{active}; if ($value eq 1){ print ("Device with the MAC-Adress: $mac is active!\n"); }elsif($value eq ""){ print ("Device with the MAC-Adress: $mac is disabled!\n"); }}else{ print ("Device with the MAC-Adress: $mac, the value of $input is: ", $item->{$input}, "\n"); } };