#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Code Sniplet #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ my $data_structure = decode_json($client->responseContent()); print Dumper($data_structure); # Output of print Dumper($data_structure); $VAR1 = { 'Resources' => [ 'displayName' => 'User 1', 'userName' => 'user1@test.com', 'id' => '1234567', 'meta' => { 'created' => '2018-04-16T11:57:19.376Z' } }, { 'displayName' => 'User 2', 'userName' => 'user2@test.com', 'id' => '1234568', 'meta' => { 'created' => '2018-04-16T11:59:27.111Z' } }, { 'displayName' => 'User 3', 'userName' => 'user3@test.com', 'id' => '12345679', 'meta' => { 'created' => '2018-11-21T14:49:33.821Z' } }, ], 'totalResults' => 3, 'itemsPerPage' => 50, 'startIndex' => 1, 'schemas' => [ 'urn:ietf:params:scim:api:messages:2.0:ListResponse' ] }; # Normally @elements is filled by entries from a config-file # but for make it easy, I set the values here my @elements; push(@elements,"userName"); push(@elements,"displayName"); push(@elements,"meta.created"); foreach $item ( @{ $data_structure->{Resources} } ) { foreach $element (@elements) { # Convert a . to }->{ in order for meta.created to look like meta}->{created $element =~ s/\./}->{/g; # This works for all elements except of meta}->{created $deref = $item->{$element}; print "Convert: \$item->{" . $element . "}\t\t\t" . $deref . "\n"; } # But this works deref = $item->{meta}->{created}; print "When use direct: \$item->{meta}->{created}\t" . $deref . "\n"; print "\n"; } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Output: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Convert: $item->{userName} user1@test.com Convert: $item->{displayName} User 1 Use of uninitialized value $deref in concatenation (.) or string at /home/dczesak/cis4oci/cis4oci.pl line 291. Convert: $item->{meta}->{created} When use direct: $item->{meta}->{created} 2018-04-16T11:57:19.376Z Convert: $item->{userName} user2@test.com Convert: $item->{displayName} User 2 Use of uninitialized value $deref in concatenation (.) or string at /home/dczesak/cis4oci/cis4oci.pl line 291. Convert: $item->{meta}->{created} When use direct: $item->{meta}->{created} 2018-04-16T11:59:27.111Z Convert: $item->{userName} user3@test.com Convert: $item->{displayName} User 3 Use of uninitialized value $deref in concatenation (.) or string at /home/dczesak/cis4oci/cis4oci.pl line 291. Convert: $item->{meta}->{created} When use direct: $item->{meta}->{created} 2018-11-21T14:49:33.821Z