Hi
I'm having a problem where a variable is not being interpreted instead the name of the variable is being displayed.
sub one
{
# Some code here that sets following variable
$wcnode="avalue"
}
sub two
{
$hostname=myhost;
#Read in a config file with key/value pairs separated by '='
foreach $line (@configfile)
{
($key, $value) = split(/\=/, $line);
chomp($key);
chomp($value);
%myhostnameHash->{$key} = $value;
}
# Then set a variable that is equal to a variable defined earlier in script
$installdir = "$myhostnameHash{$hostname}";
print "Value of installdir is $installdir\n";
}
# Main
&sub_one;
&sub_two;
$configfile is a flat text file that contains e.g. the following:
myhost=$wcnode
When I call the print statement in 'sub two' what is returned is:
$wcnode
Instead of the value of $wcnode - 'avalue'
I've set a variable to another variable many times before without any problems. E.g $x = $y
Is there something I need to do to to evaluate the variable??
Any help appreciated
Thanks!
I'm having a problem where a variable is not being interpreted instead the name of the variable is being displayed.
sub one
{
# Some code here that sets following variable
$wcnode="avalue"
}
sub two
{
$hostname=myhost;
#Read in a config file with key/value pairs separated by '='
foreach $line (@configfile)
{
($key, $value) = split(/\=/, $line);
chomp($key);
chomp($value);
%myhostnameHash->{$key} = $value;
}
# Then set a variable that is equal to a variable defined earlier in script
$installdir = "$myhostnameHash{$hostname}";
print "Value of installdir is $installdir\n";
}
# Main
&sub_one;
&sub_two;
$configfile is a flat text file that contains e.g. the following:
myhost=$wcnode
When I call the print statement in 'sub two' what is returned is:
$wcnode
Instead of the value of $wcnode - 'avalue'
I've set a variable to another variable many times before without any problems. E.g $x = $y
Is there something I need to do to to evaluate the variable??
Any help appreciated
Thanks!