in reply to Re^2: Complicated datastructre and after merging giving numeric value need help!!
in thread Complicated datastructre and after merging giving numeric value need help!!
Your code in sub locallb_get_member_v2 { constructs a weird data structure and contains stuff that makes it hard to believe this is meant as such:
$members{ $status->{'address'} = $member->{'port'}};
Are you sure that this code is intended as such? Did you maybe mean the following? Note the placement of curly braces
$members{ $status->{'address'}} = $member->{'port'};
Also, are you using the strict pragma? I can't find where you declare $status, but you use it in the next line:
$members{ $status}->{'enabled'} = $ENABLED_STATUS_MAP->{ $status->{' +enabled_status'} }
If your problem is that you are unclear about where parentheses go when assigning things to hashes, I recommend using intermediate variables to store the elements and use sequences of very simple assigments. What key in %members did you want to assign to? $members{ $status } or $members{ $status->{'enabled'} }?
I recommend restructuring all your hash assignments like the following structure:
# Restructure the following line # $members{ $status}->{'enabled'} = $ENABLED_STATUS_MAP->{ $status-> +{'enabled_status'} } # ... into lines that end up $members{ $key }= $value; my $key= $status; my $value= $ENABLED_STATUS_MAP->{ $status->{'enabled_status'} }; warn "Assigning '$key'='$value' in results"; $members{ $key }= $value;
If you read your code like that, it seems highly unlikely to me that you really meant that. Maybe you meant the following?
# $members{ 'enabled' }= $ENABLED_STATUS_MAP->{ $status->{'enabled_s +tatus'} } # ... into lines that end up $members{ $key }= $value; my $key= 'enabled'; my $value= $ENABLED_STATUS_MAP->{ $status->{'enabled_status'} }; warn "Assigning '$key'='$value' in results"; $members{ $key }= $value;
|
|---|