Hi Tassilo (and CKC),
In article <[EMAIL PROTECTED]>, Tassilo Von Parseval wrote:
> On Sat, May 31, 2003 at 01:50:51AM +0200 Kevin Pfeiffer wrote:
>
>> I use a function to return a value:
>> "$ENV{HOME}/perl/qotw/qotw13/mb"; which is then assigned to $mb
>>
>> But the $ENV{HOME} part is not being interpreted, so this sample:
>>
>> my $mb = get_config('mb', '.get_quiz');
>> print "$mb\n";
>> exit;
>>
>> produces literally: "$ENV{HOME}/perl/qotw/qotw13/mb" instead of:
>> /home/pfeiffer/perl/qotw/...
>
> Can you post the (potentially) relevant bits of get_config()? Sounds as
> though this function reads in a configuration file and returns the
> requested values. Is "$ENV{HOME}/perl/qotw/qotw13/mb" one such line of
> this config file? If so, it would be data and not code and you'd have to
> eval() it or so.
Sorry about leaving out the routine:
sub get_config {
my ($setting, $cfg_file) = @_; # setting is 'mb'
open DATA, "< $ENV{'HOME'}/$cfg_file"
or die "Error, could not open $cfg_file : $!";
while (<DATA>) {
next if (/^[#\s]*$/);
$result = $1 if (/^$setting\s*=\s*"?([^"]*)"?\s*$/);
}
close DATA;
return $result;
}
Data file looks like:
mb = "$ENV{'HOME'}/perl/qotw/qotw13/mb"
It already occurred to me that I might need an eval and I've tried using it
in every position and way possible it seems, but the env variable still
doesn't get interpreted.
--
Kevin Pfeiffer
International University Bremen
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]