in reply to Re^3: How to get specific hash elements?
in thread How to get specific hash elements?

But is it possible to have a scalar for each "fixed_name" assigned the value of "value"? I suppose a better representation of the hash would be:
$VAR1 = 'random_name '; $VAR2 = { 'Fixed_name1 ' => { 'value ' => undef }, 'Fixed_name2 ' => { 'value ' => undef } }; $VAR3 = 'random_Name '; $VAR4 = { 'Fixed_name1 ' => { 'value ' => undef }, 'Fixed_name2 ' => { 'value ' => undef } };
The fixed names are always going to be the same but there will be hundreds of random names. I want to return the value of the fixed name to another function that will display this value on a webpage for each random name. There will only ever be 1 element for value. I hope I'm explaining this better each time and not just making it twice as confusing :-)

Replies are listed 'Best First'.
Re^5: How to get specific hash elements?
by Roy Johnson (Monsignor) on May 14, 2007 at 18:05 UTC
    It sounds like you just want your structure to be like
    $VAR2 = { 'Fixed_name1 ' => 'value ', 'Fixed_name2 ' => 'value ' };
    Then your original code would do what you expect. So assign just the value, rather than a hashref that uses the value as a key.

    Caution: Contents may have been coded under pressure.