Importing environment variables to Perl

后端 未结 3 1211
甜味超标
甜味超标 2021-01-15 03:33

I\'m not sure if importing is the right word to use. I\'m a beginner in both Perl and Bash. I have set a variable on Bash, so when I do:

echo $PRDIR
         


        
3条回答
  •  抹茶落季
    2021-01-15 03:55

    If you want Bash to export a variable into the environment so it's accessible to programs, you can use the export builtin:

    export PRDIR
    

    Inside Perl, you would then access it using the %ENV hash:

    my $varex = $ENV{"PRDIR"};
    print "\$varex is: $varex\n";
    

提交回复
热议问题