Hi
I am trying to create a structure which holds names and values which will later be translated into linux environment variables.
For example: $hash{VAR1}="me" will later turn into an environment variable called $VAR1 which value will be "me".
However, i would like to do it in a more sophisticated way where each variable has a priority. This way, i can decide that a certain variable will be created before the other.
I would like my structure to look something like:
In this way, $VAR1 will be created before $VAR2.$hash{10}{VAR1}="me" $hash{20}{VAR2}="you"
My problem here is efficiany: during the program, i would like to run queries on this structure so i can know the value of a variable and it's priority.
For example: if my structure would be built in the way i described above, i could just run a statement like if($hash{20}) { ... } to check if a priority i have given already exists, however, if i wanted to know the value of a variable, i would have to run a foreach loop which would go through the whole hash inorder to find it.
If i build the structure as following:
$hash{VAR1}{priority}{value1}
It would be easier for me to get the value of the variable, or check if it already exists, however, if i would like to check if a priority exists, or if one priority is lower than another, i would have to go through the whole hash again to check it.
What would be your suggestion for building such a structure ?
Thanks
20040718 Janitored by Corion: Converted TR tags to P tags
In reply to a hash with priority by meirgold
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |