#! perl use strict; use warnings; use Data::Dump; my $doc = { _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' }, }, ], }, }, }, }; print "BEFORE:\n"; dd $doc; print '-' x 30, "\n"; my @new_formulae = qw( abc mno xyz ); for my $sheet (keys %{ $doc->{_source}{sheets} }) { for my $columns (@{ $doc->{_source}{sheets}{$sheet}{formulates} }) { for my $one (keys %{ $columns }) { # print $columns->{$one}{formula}, $/; $columns->{$one}{formula} = shift @new_formulae; } } } print "AFTER:\n"; dd $doc; print '-' x 30, "\n"; #### 14:40 >perl 1673_SoPW.pl BEFORE: { _source => { sheets => { sheet1 => { 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", }, }, ], Sheet_Name => "Ex-Sheet", }, }, }, } ------------------------------ AFTER: { _source => { sheets => { sheet1 => { formulates => [ { "0" => { colName => "Ex-Col1", formula => "abc", total => "false" }, }, { 1 => { colName => "Ex-col2", formula => "mno", total => "false" }, }, { 2 => { colName => "Ex-Col3", formula => "xyz", total => "false" }, }, ], Sheet_Name => "Ex-Sheet", }, }, }, } ------------------------------ 14:40 >