I have a %parallel_hash with indexed key names 0-2:
%parallel_hash
(function_name_0 => "sharp_mpi_steps::run_mpirun",
params_name_0 => ("reporter","xml_obj",$hash{value}),
function_name_1 => "sharp_mpi_steps::run_mpirun",
params_name_1 => ("reporter","xml_obj",$hash{value}),
(function_name_2 => "sharp_mpi_steps::run_mpirun",
params_name_2 => ("reporter","xml_obj",$hash{value})
I would like to update the $hash{value} content with an indexed text. To each $hash{value} inside params_name_$i, simply add another key and value: reporter_message => "process_$i"
my code is:
package delete;
use strict;
use warnings FATAL => 'all';
my %parallel_hash;
my %hash_mpi;
$hash_mpi{value}->{bind_to} = "none";
for (my $i=0;$i<=2;$i++)
{
my %hash;
$hash{value} = $hash_mpi{value};
$parallel_hash{"function_name_$i"} = "sharp_mpi_steps::run_mpirun";
@{$parallel_hash{"params_name_$i"}} = ("reporter","xml_obj",$hash{value});
$parallel_hash{"params_name_$i"}->[2]->{reporter_message} = "process_$i";
}
print ("Done");
1;
I would like to get:
%parallel_hash
'function_name_0' = "sharp_mpi_steps::run_mpirun"
'params_name_0' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_0"
'function_name_1' = "sharp_mpi_steps::run_mpirun"
'params_name_1' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_1"
'function_name_2' = "sharp_mpi_steps::run_mpirun"
'params_name_2' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_2"
The problem is that after the "reporter_message" key is added, it updates all the previous "params_name_$i" as well:
%parallel_hash
'function_name_0' = "sharp_mpi_steps::run_mpirun"
'params_name_0' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_2"
'function_name_1' = "sharp_mpi_steps::run_mpirun"
'params_name_1' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_2"
'function_name_2' = "sharp_mpi_steps::run_mpirun"
'params_name_2' =
[0] = "reporter"
[1] = "xml_obj"
[2] =
'bind_to' = "none"
'reporter_message" = "process_2"
How can I avoid this updating?