I have a perl script (abc.pl) and 2 config files (one var.pl and one config.txt)
Now
in var.pl
$admin_userid = "admin";
$guest_userid = "guest";
in config.txt – this has the value of user – can be either admin or guest
user=admin/guest
in abc.pl
require var.pl
$get_user = admin or guest (get this value from config.txt)
**$myfinal_userid = ??**
I want the value of myfinal_user_id as admin if user in config.txt is admin and guest if it is guest.
i.e. based on $get_user’s value I want the value of userid – ${$get_user}.”_userid”
eg: if config.txt has user=admin, the $get_user = admin and I want $myfinal_userid = $admin_userid. similarly for guest. This has to be dynamic.
Finally what I want is, know the user from config.txt and based on it, get the userid from var.pl and store that in myfinal_userid.
Let me know how can I achieve this in perl?
Use a hash to store the id’s: