in reply to Re: How to create variables for each hash key that has a value.
in thread How to create variables for each hash key that has a value.
Thank you LanX and GrandFather for your response.
this is a very puzzling request, because how do you write code for variables which may or may not exist?These are fields that will/won't be sent from front end. My code for each of these fields is in separate if(@arr_0), if($scal_1) blocks. So if any of these variables don't exist, the related code will not execute.
Why? What is the bigger goal?The reasons I am trying to find if this is possible is:
1) If this is possible, I'll create variables only for those fields that were selected by user. (And so will have non empty values)
2) This will also prevent need for any immediate code changes at back end when fields are added or removed from the front end. If a field is removed from front end, the variable will not be created for it and related code block for that field will not execute. When fields is added at least the variable will be created for new field. I can make use of that. I'll still have to write code specific to that field.
Do you know that a hash value can be anything, including a reference to another (nested) hash or a reference to an array?Thank you for suggesting this. I know about it but will be thinking in that direction now. Will try to see if I can make use of this somehow.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to create variables for each hash key that has a value.
by LanX (Saint) on Jun 26, 2019 at 22:13 UTC |