Hi
Am hoping someone can help with some probs I'm having with variables. I'm more of a perl scripter and am fairly new to tcl. I have a script comprised of various procs and a main. The main reads in a property file and sets several variables based on contents of that file then calls procs.
There are 3 variable types I'm interested in:
$vhostname
$aliaslist
$portlist
I've got foreach loop that loops through the list of $vhostnames and for each iteration sets the value of $aliaslist and $portlist. I'm intending that the values of $aliaslist and $portlist will be equal to 2 variables of same name read in from the property file. In the property file these variable names are prefixed with the value of $vhostname. Perhaps this will make more sense:
If $vhostname=myvhost1 there would be 2 further variables in the property file as follows:
myvhost1_aliaslist
myvhost1_portlist
Likewise if $vhostname=myvhost2 the other variables would be :
myvhost2_aliaslist
myvhost2_portlist
Okay, here's how I am trying to acheive by using concat and join but obviously getting it wrong. (Apologies in advance to any seasoned tcl'rs if this is truly horrible but I'm learning
foreach vhostname $vhostnames {
# Set the values of $aliaslist $portlist based on
# value of $vhostname
set concatalias [concat $vhostname _aliaslist]
set concatport [concat $vhostname _portlist]
# Use join to remove spaces in variable name
set aliases [join $concatalias ""]
set ports [join $concatport ""]
# Now set $aliaseList $portList to values supplied in property file global variables
set aliaslist [list $aliases]
set portlist [list $ports]
puts "Value of alias list is $aliaslist"
puts "Value of port list is $portlist"
}
The two final puts, instead of returning the values of the variables specified in the property file are simply returning the name of the variable e.g. myvhost1_aliaslist. I can understand why based on the code I've written but would really appreciate any help to return values not the name.
Many thanks in advance
Jules
Am hoping someone can help with some probs I'm having with variables. I'm more of a perl scripter and am fairly new to tcl. I have a script comprised of various procs and a main. The main reads in a property file and sets several variables based on contents of that file then calls procs.
There are 3 variable types I'm interested in:
$vhostname
$aliaslist
$portlist
I've got foreach loop that loops through the list of $vhostnames and for each iteration sets the value of $aliaslist and $portlist. I'm intending that the values of $aliaslist and $portlist will be equal to 2 variables of same name read in from the property file. In the property file these variable names are prefixed with the value of $vhostname. Perhaps this will make more sense:
If $vhostname=myvhost1 there would be 2 further variables in the property file as follows:
myvhost1_aliaslist
myvhost1_portlist
Likewise if $vhostname=myvhost2 the other variables would be :
myvhost2_aliaslist
myvhost2_portlist
Okay, here's how I am trying to acheive by using concat and join but obviously getting it wrong. (Apologies in advance to any seasoned tcl'rs if this is truly horrible but I'm learning
foreach vhostname $vhostnames {
# Set the values of $aliaslist $portlist based on
# value of $vhostname
set concatalias [concat $vhostname _aliaslist]
set concatport [concat $vhostname _portlist]
# Use join to remove spaces in variable name
set aliases [join $concatalias ""]
set ports [join $concatport ""]
# Now set $aliaseList $portList to values supplied in property file global variables
set aliaslist [list $aliases]
set portlist [list $ports]
puts "Value of alias list is $aliaslist"
puts "Value of port list is $portlist"
}
The two final puts, instead of returning the values of the variables specified in the property file are simply returning the name of the variable e.g. myvhost1_aliaslist. I can understand why based on the code I've written but would really appreciate any help to return values not the name.
Many thanks in advance
Jules