for ( my $indx = 0; $indx <=2; $indx++){
That is usually written as:
for my $indx ( 0 .. 2 ) {
# Make a reference to the hash reference my $work_package = \%{$work_request};
You have a hash reference in $work_request which you then dereference as %{$work_request} and then get a reference to the original hash with \%{$work_request}. You can accomplish the same thing more simply with:
my $work_package = $work_request;
my @list = @{$work_package->{$key}}; for (my $a_id=0; $a_id <= $#list; $a_id++) { $list[$a_id]=$indx; print " $list[$a_id]\t"; } print "\n";
You are copying the contents of @{$work_package->{$key}} to @list so any changes to the contents of @list will disapear when the loop ends. The for loop is usually written as:
for my $a_id ( 0 .. $#list ) { $list[$a_id]=$indx; print " $list[$a_id]\t"; }
In reply to Re: Array of dynamic Hash how to preserve the values
by jwkrahn
in thread Array of dynamic Hash how to preserve the values
by ckandreou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |