I'm trying to set a variable I previously set in a Perl script as an environment variable, but it seems to not realize the parameter I'm passing in is a variable and not the actual path I want.
For example, when I ru开发者_如何学编程n this:
$ENV{'ENV_VARIABLE'}='\'$file_path\'';
print($ENV{'ENV_VARIABLE'});
I only get:
'$file_path'
Is there any way I can tell it that what I'm passing in is actually a variable and not a literal string?
In Perl, single quoted strings do not interpolate variables. You want to use a double quote:
$ENV{'ENV_VARIABLE'}= "'$file_path'";
In that line, the rvalue is interpreted as q{'} . $file_path . q{'}
where q{'}
is a fancy way of writing '\''
, which is a bit harder to read.
精彩评论