P
prattm
I am reading in a config file that has a bunch of absolute file paths,
most with embedded environment variables, such as:
${HOME}/bin/myscript.pl
To ultimate goal is to do some file tests on these items, specifically
readlink, but I can't because of the embedded env variables. So I
thought I would try a nifty little search and replace:
$file =~ s/\${/\$ENV{/;
The goal being the replace all occurences of "${" with "$ENV{" so that
Perl will resolve the env variables for me using the ENV hash. The
search and replace works, but I still get errors passing in the new
variable to readlink because Perl is not evaluating the $ENV{...}
substrings first.
Any ideas of how to get around this? My fallback is to just do
something like
$file = `echo $file`;
But this seems a bit goofy to me and it seems like there ought to be a
way to do in Perl.
Thanks, Mike
most with embedded environment variables, such as:
${HOME}/bin/myscript.pl
To ultimate goal is to do some file tests on these items, specifically
readlink, but I can't because of the embedded env variables. So I
thought I would try a nifty little search and replace:
$file =~ s/\${/\$ENV{/;
The goal being the replace all occurences of "${" with "$ENV{" so that
Perl will resolve the env variables for me using the ENV hash. The
search and replace works, but I still get errors passing in the new
variable to readlink because Perl is not evaluating the $ENV{...}
substrings first.
Any ideas of how to get around this? My fallback is to just do
something like
$file = `echo $file`;
But this seems a bit goofy to me and it seems like there ought to be a
way to do in Perl.
Thanks, Mike