{ "sheets": { "sheet1": { "Sheet_Name": "Ex-Sheet", "formulating": [ { "0": { "colName": "Ex-Col1", "formula": "((column08=Submit | column10=Delivered | column09=Something) & (column08=Delivered | column09=Something))", "total": "false" }, "1": { "colName": "Ex-Col1", "formula": "((column08=Submit | column10=Delivered | column09=Something) & (column08=Delivered | column09=Something))", "total": "false" }, "2": { "colName": "Ex-Col1", "formula": "(column08=Submit & column10=Delivered & column09=Something)", "total": "false" } } ] } } } #### [$VAR1->{'request'}{'body'}{'_source'}{'sheets'}{'sheet1'}{'forumle'}[0]{'1'}{'formula'}{'query'}{'constant_score'}{'filter'}{'bool'}{'should'}[0],$VAR1->{'request'}{'body'}{'_source'}{'sheets'}{'sheet1'}{'forumle'}[0]{'1'}{'formula'}{'query'}{'constant_score'}{'filter'}{'bool'}{'should'}[1],{'.... #### if { ..... } else { my %main_hash = (); $main_hash{"query"}{"constant_score"}{"filter"} = @condition_array[(int($condition)-1)]; my $json = encode_json \%main_hash; print Dumper \%main_hash; #printing very fine here $columns->{$one}{'formula'} = \%main_hash; #$columns is a address in $doc print Dumper $doc; #Working only for first element #exit; #print $json,$/; }