$VAR1 = { '_source' => { 'sheets' => { 'sheet1' => { 'Sheet_Name' => 'Ex-Sheet', 'formulates' => [ { '0' => { 'colName' => 'Ex-Col1', 'formula' => '((DelvSts = Deleted + RcdTyp = DelAck) & RcdTyp = DelRecpt)', 'total' => 'false' } }, { '1' => { 'colName' => 'Ex-col2', 'formula' => '((DelvSts = UserIncomingSMBarred & LFR = SMSC_PR_LC_SMSC_Encoding_Error) | RcdTyp = DelRecpt)', 'total' => 'false' } }, { '2' => { 'colName' => 'Ex-Col3', 'formula' => '(RcdTyp = DelAck + OrigInf = SMPP)', 'total' => 'false' ..... and continues #### my %doc = %{ $doc }; foreach my $sheet (keys %{ $doc{'_source'}{'sheets'} }) { foreach my $columns (@{ $doc{'_source'}{'sheets'}{$sheet}{'formulates'} }) { my %columns = %{ $columns }; foreach my $one (keys %{ $columns }) { #print $doc{'_source'}{'sheets'}{$sheet}{'formulates'}{$columns}->{$one}{'formula'},$/; #print $doc{'_source'}{'sheets'}{$sheet}{'formulates'}{$columns}{$one}{'formula'},$/; ### I want to replace the formula variable here### } } }